我的ASP.NET MVC 3 web項目工作正常,然後重新編譯我它,現在我得到這個錯誤(一些路徑和名稱空間更改爲保護無辜者):的NullReferenceException上RouteTable.Routes
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 66:
RouteTable.Routes.MapRoute(Line 67:
"DefaultRoutes", // Route name Line 68:
"{module}/{controller}/{action}/{id}", // URL with parametersSource File: ....\Global.asax.cs
Line: 66Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Project.MvcApplication.RegisterRoutes(RouteCollection routes) in D:.....\Global.asax.cs:66 Project.MvcApplication.Application_Start() in D:.....\Global.asax.cs:139[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +4051717 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352 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) +11642112
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4865877
我在Windows 7 x64上使用IIS7.5,並將應用程序池配置爲與.NET 4和「集成」託管管道一起運行。
我試過重新啓動,也清理出bin和obj文件夾沒有成功。
這原來是很重要的一些額外的信息 - 該行從上述錯誤頁面丟失:
RouteTable.Routes.MapRoute(
"DefaultRoutes", // Route name
"{module}/{controller}/{action}/{id}", // URL with parameters
new { module = _loadedModules.FirstOrDefault().Name, controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
你能發佈你的路線嗎?它可能會有所幫助...... –