Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carlos Gómez 25 posts 55 karma points
    Nov 21, 2014 @ 01:55
    Carlos Gómez
    0

    version 7: ASP.NET 4.0 @Umbraco.Field causes an "Object reference not set to an instance of an object." error message.

     

    Hello people....

    For the last week I have been working hard implementing a website and have had nice results with Umbraco 7 and MVC model, which is the first one I use it.

    Yesterday I left my work with the website working nicely and very proud to go today to show it to my customer.  One hour before the meeting, and very confident with what it has been working nicely, ran the website and the home page showed perfectly.  Then I clicked to a normal text-page and suddenly and unexpectedly, it is showing the awful error message that I am including here.

    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 147:          <div class="row animated opacity mar-bot20" data-andown="fadeIn" data-animation="animation">
    Line 148:               <div class="col-xs-12 col-sm-4"><h3>Contáctenos:</h3>
    Line 149:                 @Umbraco.Field("cstmInformacionDeContacto", recursive: true);
    Line 150:
    Line 151:               </div>


    Source File: c:\Users\cgomez\Documents\My Web Sites\IIDH\Views\Master.cshtml    Line: 149 

    Stack Trace: 

    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP._Page_Views_Master_cshtml.Execute() in c:\Users\cgomez\Documents\My Web Sites\IIDH\Views\Master.cshtml:149
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
       System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +97
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
       System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +233
       System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
       System.Web.WebPages.WebPageBase.Write(HelperResult result) +71
       System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +64
       System.Web.WebPages.WebPageBase.PopContext() +246
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95
       System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +258
       System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
       Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +93
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +295
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
       System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
       System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
       System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
       System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
    



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


    First thing I thought was that I misstyped the field name, or the field was removed or empty.  It was good.  Then, I thought that it could be something regarding the "recursive" parameter, removed it and the same result. 

    Then I removed completely the line, and now the same error but pointing to another "@" tag...

     

    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 141:      <!-- spacer section:stats -->
    Line 142:                           
    Line 143:     @RenderSection("ejesTransversales",false)
    Line 144:        
    Line 145:   <section id="footer" class="section footer">


    Source File: c:\Users\cgomez\Documents\My Web Sites\IIDH\Views\Master.cshtml    Line: 143 

    Stack Trace: 

    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP._Page_Views_Master_cshtml.Execute() in c:\Users\cgomez\Documents\My Web Sites\IIDH\Views\Master.cshtml:143
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
       System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +97
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
       System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +233
       System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
       System.Web.WebPages.WebPageBase.Write(HelperResult result) +71
       System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +64
       System.Web.WebPages.WebPageBase.PopContext() +246
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95
       System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +258
       System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
       Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +93
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +295
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
       System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
       System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
       System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
       System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


    Important to remark that the home page is working perfectly, the problem is with a text page that uses the TextPage the same master.cshtml template, and until yesterday it was working pefectly.

    Any idea what am I doing wrong?  

    Thanks in advance.

  • Carlos Gómez 25 posts 55 karma points
    Nov 21, 2014 @ 06:34
    Carlos Gómez
    0

    I tried to rebuild the site section by section.

    Now I am getting this error:

    Server Error in '/' Application.


    Input string was not in a correct format.

    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.FormatException: Input string was not in a correct format.

    Source Error: 

    Line 81: <!--Carousel Section -->
    Line 82: @RenderSection("carrousel",false)}
    Line 83: @RenderSection("encabezadoPaginaContenido",false) Line 84: <!-- /carousel -->   
    Line 85:        <!-- services -->
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Nov 21, 2014 @ 07:37
    Jan Skovgaard
    0

    Hi Carlos

    That's very unfortunate indeed - Did you deploy the website to a server before showing it to your customer? Or is this happening on the very same machine?

    What property editors are being used for the macro on line 82 and 83? Is those fields empty in some places?

    /Jan

  • Carlos Gómez 25 posts 55 karma points
    Nov 21, 2014 @ 13:41
    Carlos Gómez
    0

    Hello Jan.

    It was on the same development machine.  That is the weirdest thing.  I was using it smoothly and nice.  

    Nevertheless, ignore my second post (the one that causes the Invalid Format error) because I think I did locate in a specific part of the code.  The problem with the "Object reference not set to an instance of an object" is still being caused in the Content page (second level under the Home) that uses the same Master page as in Home, but now it seems that doesn't like the Content page anymore.

    Any idea relating to that?

    Thanks.

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Nov 21, 2014 @ 14:01
    Jan Skovgaard
    0

    Hi Carlos

    Do you use any 3rd party packages that could be the cause? Or have you perhaps been hooking into some of the backoffice events or been using the API some other way?

    /Jan

  • Carlos Gómez 25 posts 55 karma points
    Nov 21, 2014 @ 14:17
    Carlos Gómez
    0

     

    hi!

    Not at all... I just installed and using the ImageGen package, and the error was showing up befor and after installing that package.

    I stripped down the content page... the only content of the ContentPage template is this:

    ...............................

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{    Layout = "Master.cshtml";

    }

    <p>hello </p>

    ..................................

    And the error is pointing to the Master.cshtml document, with or without recursive.   

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error: 

    Line 146:          <div class="row animated opacity mar-bot20" data-andown="fadeIn" data-animation="animation">
    Line 147:               <div class="col-xs-12 col-sm-4"><h3>Contáctenos:</h3>
    Line 148: @Umbraco.Field("cstmInformacionDeContacto", recursive: true); Line 149:              </div>
    Line 150:               <div class="col-xs-12 col-sm-4"><img src="@Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("cstmImagenpatrocinio")).Url"></div><div class="col-xs-12 col-sm-4"><div class="text-right">


    Source File: c:\Users\cgomez\Documents\My Web Sites\IIDH\Views\Master.cshtml    Line: 148 

    If I remove that line, to find out if the problem was in that custom field, the error shows up in a different line:

    Line 140:      <!-- spacer section:stats -->
    Line 141:                           
    Line 142: @RenderSection("ejesTransversales",false) Line 143:      
    Line 144:   <section id="footer" class="section footer">

    No backoffice events nor API use at all... it is a simple content site.

    Any other idea?

     

  • Carlos Gómez 25 posts 55 karma points
    Nov 22, 2014 @ 04:29
    Carlos Gómez
    1

    I found the problem!!!!

    one failed demo and a day of hard testing, finallly I spoted the line that is causing the null object reference:

    @Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("cstmImagenpatrocinio")).Url

    If I include this @ call, it causes the problem in the next @Umbraco call, that is why it didn't fix anything to remove the line that was causing the "Object reference not set to an instance of an object" error.  Basic: you should check not only the line that is causing the problem, but lines after and lines before too.

    This trouble line works fine in Home.cshtml that inherits Master.cshtml (where the line is), but causes the error in ContentPage.cshtml that inherits Master.cshtml too.  

    Could somebody let me learn why this could be happening?

    Thanks in advance.

     

Please Sign in or register to post replies

Write your reply to:

Draft