Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » NullReferenceException on template

NullReferenceException on template

Gaëtan
Reply

Hello,

 

I'm trying to upgrade my solution (based on wrap) to version 9, but I'm running in some trouble. The backend runs fine but when I try to access the frontend I get this exception :

Exception in template (Designs/Dwsimple/_parsed/fullwidth.parsed.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.ccabdcfbedb.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()

As you can see it doesn't specify a line number. It seems to come from my master page template but the file fullwidth.parsed.html is nearly 3000 lines long, so it makes it difficult to pinpoint an error in it. I haven't been able to debug (I use Visual Studio 2013). Do you have any tip to debug that kind of error ?

 

Thanks


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Gaƫtan

The missing line numbers is a bug in our build system. We have made a change to the Razor engine to support line numbers, but we accidently updated the reference to the official version from the nuget feed - hence the missing numbers. So, you will get them back with a later release, probably 9.3 i January.

Until then you have to debug the crappy way - cut out code and see if that was the block with the error.

We also have a set of DW9 wrap templates that you can find under download.

BR Nicolai

Votes for this answer: 1
 
Gaetan Caro
Reply

Ok thanks. It took me a long time but I managed to tackle the issue.

 
Nicolai Pedersen
Reply

Glad to hear.

Sorry about the inconvenience! I hope I fixed it yesterday, but it needs a lot of testing to get out...

BR Nicolai

 
Gaetan Caro
Reply

For the record, it was because, on my master page, I was calling some website settings with PageView.Area.Item["Key"] instead of GetXXX("Item.Area.Key"). The first one is of course unnecessary on a page template and can return null (which isn't the case with the second one).

Not sure which one exactly was causing a problem as I replaced all calls at once, but that was it.

 
Nicolai Pedersen
Reply

Ah - that explains it.

Thanks for sharing - good to know for other upgrades!

 

You must be logged in to post in the forum