2

我的 global.asax 文件(在我的 asp.net 应用程序中)中有以下代码...

在此处输入图像描述

我在堆栈跟踪中有以下错误:

[NullReferenceException: Object reference not set to an instance of an object.]
Digita.Tustena.Global.Application_Start(Object sender, EventArgs e) +133

[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext       context, HttpApplication app) +3985477
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375

[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4782309

我的代码有什么问题?我感谢您的帮助...

4

1 回答 1

2

查看 Global.asax.cs 文件中的 Application_Start 方法。你在那里有一个空引用。放置一个 try/catch 并使用调试器查看哪个对象为空。

如果您使用 dll 部署 pdb 文件,则堆栈跟踪还将包含行号。还要将调试信息设置为完整:项目属性 -> 构建 -> 高级 -> 调试信息(http://stackoverflow.com/a/3791997/57369)

于 2012-12-06T10:28:29.523 回答