问题是,我经常得到在生产现场(ASP.NET MVC 3)错误,但无法在本地重现此错误。 例外的文本是:
ExceptionType: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace:
at System.Collections.Specialized.NameObjectCollectionBase.BaseGetAllKeys()
at System.Collections.Specialized.NameValueCollection.get_AllKeys()
at MvcSiteMapProvider.MvcSiteMapNode.get_MetaAttributes()
at MvcSiteMapProvider.Web.Html.SiteMapNodeModelMapper.MapToSiteMapNodeModel(SiteMapNode node, MvcSiteMapNode mvcNode, IDictionary`2 sourceMetadata)
at MvcSiteMapProvider.Web.Html.SiteMapPathHelper.BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode)
at MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper, String templateName)
at ASP._Page_Views_Shared__LoggedInLayout_cshtml.Execute() in c:\Solution\Sites\Project2Site\Views\Shared\_LoggedInLayout.cshtml:line 86
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.WebPages.WebPageBase.Write(HelperResult result)
at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
at System.Web.WebPages.WebPageBase.PopContext()
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
我在本地没有这样的错误。 这里就是我调用MvcSiteMap().SiteMapPath()
方法:
可能有人有过同样的问题。 如果是的话,请分享你的解决方案。
提前致谢。