Suddenly started getting 'object reference null' exception in Admin - Menu.cshtml

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 11 ans
Please help, it was running fine, but suddenly Menu.cshtml in Administration project started throwing null reference exception. I have dropped the database, re-installed the application, but still the issue persists.

Please see below the stack  trace generated:-
--------------------------------------------------------------------------------------------------------------


Server Error in '/' Application.

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 15: }
Line 16: @{
Line 17:     Html.Telerik().Menu().Name("Admin")
Line 18:     .BindTo("admin", (item, siteMapNode) =>
Line 19:     {

Source File: d:\Miki\NopCommerce1\Presentation\Nop.Web\Administration\Views\Shared\Menu.cshtml    Line: 17

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.Mvc.Infrastructure.Implementation.ControllerAuthorization.IsAccessibleToUser(RequestContext requestContext, String controllerName, String actionName, RouteValueDictionary routeValues) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\Infrastructure\Implementation\ControllerAuthorization.cs:75
   Telerik.Web.Mvc.Infrastructure.Implementation.NavigationItemAuthorization.IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\Infrastructure\Implementation\NavigationItemAuthorization.cs:38
   Telerik.Web.Mvc.UI.<>c__DisplayClass2`1.<IsAccessible>b__1(T item) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\NavigatableExtensions.cs:216
   System.Linq.Enumerable.Any(IEnumerable`1 source, Func`2 predicate) +151
   Telerik.Web.Mvc.UI.NavigatableExtensions.IsAccessible(IEnumerable`1 items, INavigationItemAuthorization authorization, ViewContext viewContext) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\NavigatableExtensions.cs:216
   Telerik.Web.Mvc.UI.NavigationItemContainerExtensions.WriteItem(TItem item, TComponent component, IHtmlNode parentTag, INavigationComponentHtmlBuilder`1 builder) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\NavigationItemContainerExtensions.cs:42
   Telerik.Web.Mvc.UI.<>c__DisplayClass4.<WriteHtml>b__3(MenuItem item) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:171
   Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\Extensions\EnumerableExtensions.cs:61
   Telerik.Web.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:171
   Telerik.Web.Mvc.UI.ViewComponentBase.Render() in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBase.cs:167
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:149
   ASP._Page_Administration_Views_Shared_Menu_cshtml.Execute() in d:\Miki\NopCommerce1\Presentation\Nop.Web\Administration\Views\Shared\Menu.cshtml:17
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +279
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +113
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName) +31
   ASP._Page_Administration_Views_Shared__AdminLayout_cshtml.Execute() in d:\Miki\NopCommerce1\Presentation\Nop.Web\Administration\Views\Shared\_AdminLayout.cshtml:69
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +102
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +12
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +67
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +66
   System.Web.WebPages.WebPageBase.PopContext() +262
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

----------------------------------------------------------------------------------------------------------------------

Please help if anybody knows what's gone wrong?
Il y a 11 ans
Have you added any new element to your sitemap.xml file?
Il y a 11 ans
This was happening because I replaced Telerik with newer version. Thanks for replying!
Il y a 11 ans
It's not possible because of a Telerik issue. Find a work item here.

BTW, you can fix it manually. Find more info here
Il y a 11 ans
Hello,
I'v updated telerik too and have same issue.
Downloaded telerik source. Replaced ControllerAuthorization.cs file with "fixed" one. Built MVC3 release version. Replaced old one with newly built one.
And no difference. Same error.
Any ideas?
Il y a 11 ans
Argar wrote:
Hello,
I'v updated telerik too and have same issue.
Downloaded telerik source. Replaced ControllerAuthorization.cs file with "fixed" one. Built MVC3 release version. Replaced old one with newly built one.
And no difference. Same error.
Any ideas?

I think you should better post it on the Telerik forums here
Il y a 11 ans
Looks like it works now. Thou i don't understand why it did not before. I just recompiled everything some times and now it works.
I agree its realy bad of them scheduling critical fix for next major release and just posting source fix on forum.
Il y a 11 ans
Argar wrote:
Looks like it works now.

Don't think so =((( It also worked fine on my machine for some period of time. Then crashed. Then worked. Then crashed. I would better completely remove their IsAccessibleToUser method (always return "true")
Il y a 11 ans
So far it works without faults.
I think this helped me:
First time i'v just replaced dll file in deployable files set. And no good result.
But last time I have recompiled telerik mvc. Replaced dll in packages folder of nopcommerce source.
Then i have removed references to telerik mvc in Nop.Admin & Nop.Web and added them again <- i think this was critical.
Then rebuilt solution and made deployable version (manually - because deploy.bat don't work after update).

Btw i'v also updated all other packages that was outdated - using nuget.
I'v got some problems during updates and some related to 2.5 -> 2.6 update.
The only problem i'v got during packages update is the need to change web.config a little.

After sqlcompact update the new string is added:
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
But the old one is not removed (version 4.0.0.0).
So i'v removed it so that section should look:

  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SqlServerCe.4.0" />
      <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </DbProviderFactories>
  </system.data>

Also at the end of web.config there were new section added called EntityFramework.
During startup error will occure saying that this section is unknown. It just needs to be removed completely.

Also I had a problem with 2.5->2.6 update.
Database should be updated on local machine as you stated in other threads, so that new tables will be created under [dbo].
And I had a problem with zoom pictures script not working (slimbox2).
It was enabled and was working in 2.5 but in 2.6 no - picture just opened in other browser window.
By unknown reason sometimes it worked, but mostly not.
So i'v replaced slimbox2 script with the one from authors page (the one in 2.6. package is different).
With original one you just need to change keys to rel="lightbox instead of data-gallery="lightbox.
And now it works.
Also about zoom feature. I think its better to enable it by default. And not only for main picture. But also for variants pictures. Ofcourse it can be done manually and easy... But better have it from the start.

Also after 2.6 update i'v started to loose authentication (not on local machine - but on hosting). So i'v added machine key as you suggested in other thread. And it helped.

Thanks.
Il y a 11 ans
Argar wrote:
...

Thanks for info

Argar wrote:
So i'v replaced slimbox2 script with the one from authors page (the one in 2.6. package is different).
With original one you just need to change keys to rel="lightbox instead of data-gallery="lightbox.
And now it works.

It was different in order to resolve W3C compliance issues (more info here). But it causes another issue (didn't work in IE9 and IE 10). It was fixed a yesterday (more info here)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.