2012-12-24 123 views
2

存在,您好我增加了一个类文件Global.asax中..global_asax没有命名空间中的ASP

内global_asax代码:

<%@ Application Language="C#" CodeFile="Global.asax.cs" Inherits="Global" %> 

内的global.asax.cs代码:

public partial class Global : System.Web.HttpApplication 
{} 

但我仍得到上面的错误:

The type or namespace name 'global_asax' does not exist in the namespace 'ASP' (are you missing an assembly reference?)

这里是命名空间ASP代码:

using System.Diagnostics; 
using System.Runtime.CompilerServices; 

namespace ASP 
{ 
[CompilerGlobalScope] 
public class global_asax :HttpApplication 
{ 
    [DebuggerNonUserCode] 
    public global_asax(); 
} 
} 

这里global_asax在继承HttpApplication..how如何更改这个文件,它继承了全局类

回答

0

打开Visual Studio 2010,一旦其加载

open explorer -> goto > C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 

将所需的System.ComponentModel.DataAnnotations.dll复制到您的项目“参考”文件夹中选择该参考,并在属性设置“复制本地”为true,一旦你发布它将在你的bin文件夹,并不会影响任何服务器无论是x32还是x64。

0

是你的文件真的global_asaxglobal_asax.cs?不是global.asaxglobal.asax.cs

通常情况下,global.asax将引用Global类项目的命名空间,就像这样:

<%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication1.Global" Language="C#" %> 

而且global.asax.cs将由此命名空间:

namespace WebApplication1 
{ 
    public class Global : HttpApplication 
    { 
    } 
}