将类放入App_Code文件夹中以供常用时的编译器错误

时间:2012-08-10 01:36:36

标签: class compiler-construction app-code

我已经在App_Code文件夹中放了一个类,所以我的所有源文件都应该可以访问它。 Intellisense确实看到了类(在代码隐藏中),但是当我从浏览器运行该站点时,我收到编译器错误:

**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: BC30002: Type 'ClsTranslation' is not defined.
Source Error:
Line 38:     End If    
Line 39:     
**Line 40:     Dim clsTrans As ClsTranslation**  
Line 41:     clsTrans = New ClsTranslation()  
Line 42:     lblLevel0.Text = clsTrans.GetResource("", "Modules")  

Source File: C:\inetpub\wwwroot\myproject\InfoSiteMap.aspx.vb    Line: 40

我将此网站作为网络项目运行,因此我的content/compile的构建选项App_Code/class不可用。我还尝试使用@ Reference指令将文件映射到预编译器,但这似乎仅适用于用户控件而不适用于类。还尝试将类放在命名空间中,所有结果都相同。

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

大多数情况下,当我这样做时,文件的构建操作是“内容”而不是“编译”。突出显示解决方案资源管理器中的类,然后点击f4并更改它。