“global_asax”在命名空间“ASP”中不明确?
在工程里加入Global.asax,内容如下:<%@ Application Language="C#" inherits="App_Code.Global, App_Code"%>
具体的实现在 App_Code.Global里面,编译时提示“global_asax”在命名空间“ASP”中不明确?
双击错误提示,进入到出错位置为C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sls\16185ac4\39e821d7\App_Web_5hcoczk_.3.vb(72,0)
Protected ReadOnly Property ApplicationInstance() As ASP.global_asax
Get
Return CType(Me.Context.ApplicationInstance,ASP.global_asax)
End Get
End Property
清除Temporary ASP.NET Files后,问题依旧,高手帮忙解决啊 --------------------编程问答-------------------- global_asax 的名称空间默认是你的web程序集的名称空间,即网站程序集名称;
换一下网站程序集名称;
看一下是否定义了多个global_asax --------------------编程问答-------------------- <%@ Application Language="C#" %>
检查是否存在冲突 --------------------编程问答-------------------- Global_Asax定义如下:
namespace ASP
{
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Web.Profile;
[CompilerGlobalScope]
public class Global_Asax : App_Code.Global
{
private static bool __initialized;
[DebuggerNonUserCode]
public Global_Asax()
{
if (!__initialized)
{
__initialized = true;
}
}
protected DefaultProfile Profile
{
get
{
return (DefaultProfile) base.Context.Profile;
}
}
}
}
--------------------编程问答-------------------- 确认类名没有冲突 --------------------编程问答-------------------- 查找全部 "class Global_Asax", 大小写匹配, 子文件夹, 查找结果 1, "整个解决方案"
D:\CP\App_global.asax\ASP\Global_Asax.cs(9): public class Global_Asax : App_Code.Global
匹配行: 1 匹配文件: 1 合计搜索文件: 2243
--------------------编程问答-------------------- using System;
using System.ComponentModel;
using System.Web;
namespace App_Code
{
public class Global : HttpApplication
{
private IContainer components;
private Task task;
public Global()
{
this.InitializeComponent();
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
if (this.task != null)
{
this.task.Exit();
}
}
protected void Application_EndRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
Exception baseException = base.Server.GetLastError().GetBaseException();
if (baseException == null)
{
base.Server.ClearError();
}
else
{
string str = "空";
try
{
str = HttpContext.Current.Request.Url.ToString();
}
catch
{
}
string text = "Error, PageName: " + str + "。 ErrorMsg: " + baseException.Message + " Source:" + baseException.Source + "。";
PublicFunction.WriteException(null, text);
}
}
protected void Application_Start(object sender, EventArgs e)
{
this.task = new Task();
this.task.Run();
}
private void InitializeComponent()
{
this.components = new Container();
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
{
}
}
} --------------------编程问答-------------------- Global 实现如上,设置了断点,也无法调试,运行不到。
找了相关资料,该清理都清理了,也重新生成、发布网站,就是无法执行到。
补充:.NET技术 , ASP.NET