调用App_Code文件夹中包含的类时,Configuration :: CS0103错误 [英] Configuration :: CS0103 Error When Calling Class Contained In App_Code Folder
问题描述
我在Visual Studio 2010中创建了一个简单的ASP.NET网站.我在App_Code文件夹的单独文件中包含一个静态C#类(我们称其为someClass).我在页面代码中从该类中调用一个方法,如下所示:
I have created a simple ASP.NET Website in Visual Studio 2010. I have a static C# class (lets call it someClass) contained in a separate file in the App_Code folder. I call a method from that class in my page''s code behind like so:
someVar = someClass.someMethod(someParam);
这在VS 2008中可以正确编译,但是当我将其移到IIS服务器时,出现以下错误
This compiles correctly in VS 2008 but when I move it over to my IIS server, I get the following error
(CS0103): 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 'someClass' does not exist in the current context
我为此网站创建了一个虚拟目录,启用了读取",运行脚本(例如ASP)"和""执行(例如ISAPI应用程序或CGI)".我目前没有使用命名空间(因为我以为我不需要,而且我不确定如何正确使用它们).我在做什么错?
I have created a virtual directory for this website enabling ''Read'', ''Run scripts (such ASP)'', and ''Execute (such as ISAPI applications or CGI)''. I am not currently utilizing namespaces (as I thought I would not need to and I''m not sure how to use them properly). What am I doing wrong?
推荐答案
您可能需要使用指令(可能首先添加对您"someClass"所在项目的引用)
You may need using directives (and probably first add reference to the project where your "someClass" is)
即使asp页面的名称空间与您的帮助器类相同,您也需要使用<@ Import namespace="..." %>
指令
Even in the case the namespace of the asp Page is the same as your helper classes, you need to import the namespace explicitly using the <@ Import namespace="..." %>
directive
这篇关于调用App_Code文件夹中包含的类时,Configuration :: CS0103错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!