3

像很多人一样,我遇到了 CS0103 问题,但是在使用 IIS7.5 时我还没有找到关于现有主题的好的解决方案

奇怪的是:

  • 该站点在 IIS5.1 / XP 下运行良好(至少没有这个问题)
  • 该站点在 IIS7.5 Express / XP 下运行良好(从 Visual Studio 2010 运行时)
  • 该站点在 IIS7.5 Express / W7 下运行良好(从 Visual Studio 2010 运行时)
  • 但是我在使用 IIS7.5 / W7 时遇到了这个错误

涉及此错误的类位于 App_Code 文件夹中的 BusinessLogicWrapper.cs 中(在 Visual Studio 中哪个图标是灰色的。这是否意味着它没有被考虑在内?或者仅仅是因为它是一个特殊文件夹?)。

我试图在 SessionProcessing.ashx 的开头添加一个include BusinessLogic;但它没有工作:编译器只是停在第 3 行而不是第 30 行,说它不知道它必须包含什么......

我感谢你的帮助,


更多信息:

  • 我正在运行网站的预编译版本
  • 一开始它是为IIS5.1设计的

部分解决方法是将我的虚拟目录的 bin 文件夹放入根目录。

请注意,我不再有“服务器错误”(至少目前),但该网站仍然无法正常工作(我认为不同文件的路径存在问题......)。

这不是一个明确的答案(从我自己到我自己和其他人),但也许它可以为更多实验用户提供一些想法!


网站显示的500错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'BusinessLogic' does not exist in the current context

Source Error:


Line 28:                                 (context.Request.HttpMethod == "POST" && context.Request.Params["action"] == "DELETE"))
Line 29:                 {
Line 30:                     BusinessLogic.Wrapper.WRITE_TRACE(BusinessLogic.TraceLevel.MEDIUM, "SessionProcessing.ashx End session", "sid:" + sid);
Line 31:                     int res = BusinessLogic.Wrapper.removeSession(sid);
Line 32: 

Source File: c:\Users\blabla\PrecompiledWeb\Web2\SessionProcessing.ashx    Line: 30 

SessionProcessing.ashx 的开头:

<%@ WebHandler Language="C#" Class="getsession" %>

using System;
using System.Web;
using System.Text;

public class getsession : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{

    public void ProcessRequest (HttpContext context) {
        context.Response.Clear();
        context.Response.TrySkipIisCustomErrors = true;

        String sid = context.Request.Params["sessionid"];

        try
        {
            if (sid != null)
            {
                //###############################################
                //###############################################
                if (context.Request.HttpMethod == "DELETE" ||
                                (context.Request.HttpMethod == "POST" && context.Request.Params["action"] == "DELETE"))
                {
                    BusinessLogic.Wrapper.WRITE_TRACE(BusinessLogic.TraceLevel.MEDIUM, "SessionProcessing.ashx End session", "sid:" + sid);
                    int res = BusinessLogic.Wrapper.removeSession(sid);

最后是树的图像:http: //i.stack.imgur.com/szbhA.png


App_Code/BusinessLogicWrapper.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Runtime.InteropServices;

namespace BusinessLogic
{
    /// <summary>
    /// Summary description for BusinessLogicWrapper
    /// </summary>
    public class Wrapper
    {
        //Init
        [DllImport("BusinessLogicLib.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern int init(string loginFilePath, string remoteServerName, string[] itemsConnection, int cItems);

web.config(实际上有9条重写规则)

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpCookies domain="localhost"/>
  </system.web>
  <system.webServer>
    <!-- add support for ogg files-->
    <staticContent>
      <mimeMap fileExtension=".oga" mimeType="audio/ogg"/>
      <mimeMap fileExtension=".spx" mimeType="audio/ogg"/>
      <!-- <mimeMap fileExtension=".svg" mimeType="image/svg+xml"/> -->
    </staticContent>
    <!--Disable gzip compression (otherwise server pushed data is cut when arriving on the client) -->
    <urlCompression doStaticCompression="true" doDynamicCompression="false"/>
    <rewrite>
      <rules>
        <rule name="COW API session creation">
          <match url="^session$"/>
          <action type="Rewrite" url="SessionProcessing.ashx"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
4

2 回答 2

2

为你的BusinessLogic(Wrapper)类添加适当的命名空间怎么样?

<%@ WebHandler Language="C#" Class="getsession" %>

using System;
using System.Web;
using System.Text;
using [YourProjectName].App_Code

如果是网站项目,请尝试在BusinessLogicWrapper.cs文件中完全删除命名空间:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Runtime.InteropServices;


    public class Wrapper
    {
        //Init
        [DllImport("BusinessLogicLib.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern int init(string loginFilePath, string remoteServerName, string[] itemsConnection, int cItems);

然后访问您的 Wrapper 类,如:Wrapper.WRITE_TRACE...

于 2013-03-15T16:48:06.760 回答
1

一种解决方法(如果您有更好的想法,请发表评论)是将我的虚拟目录的 bin 文件夹放入根目录。

请注意,我不再有“服务器错误”(至少目前),但该网站仍然无法正常工作(我认为不同文件的路径存在问题......)。

这不是一个明确的答案(从我自己到我自己和其他人),但也许它可以为更多实验用户提供一些想法!

于 2013-03-18T13:47:15.363 回答