'Umbraco' threw an exception of type 'System.NullReferenceException'
Hello all... we have a very strange issue here that we need community assistance on:
After upgrading from version 7.1.2 to 7.4.3 using nuget package manager and successfully loading the homepage and other views on the website, we started experiencing missing images on our custom 'product' view page.
We traced the issue back to a RenderMvcController named ProductController.cs and have attached a screenshot of the specific error as shown inside of VS. To summarize, it appears Umbraco is somehow undefined and it fails wherever we use Umbraco.Media(). This is the only controller we use this in.
Below is the offending line of code and the error. Nothing in this code has changed at all (along with every other model, view, and controller). We are using uCommerce for eCommerce purposes but I am not suspecting this as the cause at this point. Also, I have tried replacing Umbraco.Media() with MediaService calls and MS also throws the Null exception.
Can you try putting Umbraco on its own line just to be sure the problem is actually with that and not with the media? For example:
var helper = Umbraco;
var media = helper.Media(swatchImage);
var url = media.Url;
Sometimes the debugger can lead you astray, so splitting it into multiple lines should help confirm that the problem is actually with the Umbraco helper.
I have resolved the issue by changing all methods to static and moving them into a new ShopController.cs non-RenderMvcController class and then fetching the media URL as follows:
var uMedia = new UmbracoHelper(UmbracoContext.Current).TypedMedia(id);
var url = uMedia.Url;
'Umbraco' threw an exception of type 'System.NullReferenceException'
Hello all... we have a very strange issue here that we need community assistance on:
After upgrading from version 7.1.2 to 7.4.3 using nuget package manager and successfully loading the homepage and other views on the website, we started experiencing missing images on our custom 'product' view page.
We traced the issue back to a RenderMvcController named ProductController.cs and have attached a screenshot of the specific error as shown inside of VS. To summarize, it appears Umbraco is somehow undefined and it fails wherever we use Umbraco.Media(). This is the only controller we use this in.
Below is the offending line of code and the error. Nothing in this code has changed at all (along with every other model, view, and controller). We are using uCommerce for eCommerce purposes but I am not suspecting this as the cause at this point. Also, I have tried replacing Umbraco.Media() with MediaService calls and MS also throws the Null exception.
Any direction would be GREATLY appreciated!
THE LINE OF CODE:
THE ERROR:

Can you try putting
Umbraco
on its own line just to be sure the problem is actually with that and not with the media? For example:Sometimes the debugger can lead you astray, so splitting it into multiple lines should help confirm that the problem is actually with the Umbraco helper.
Thanks for the reply.
This seems to return the same error as well. I did notice that in the Locals panel that this error is shown for several other items.
Screenshot:
I have resolved the issue by changing all methods to static and moving them into a new ShopController.cs non-RenderMvcController class and then fetching the media URL as follows:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.