gpt4 book ai didi

c# - 编译器错误消息 : CS0103: The name 'BusinessLogic' does not exist in the current context

转载 作者:行者123 更新时间:2023-11-30 16:19:11 28 4
gpt4 key购买 nike

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

奇怪的是:

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

这个错误涉及的类在 BusinessLogicWrapper.cs 中,在 App_Code 文件夹中(在 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>

最佳答案

如何为您的 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...

关于c# - 编译器错误消息 : CS0103: The name 'BusinessLogic' does not exist in the current context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15437309/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com