alex-klock / razor-mediator-4-tridion

Automatically exported from code.google.com/p/razor-mediator-4-tridion
1 stars 4 forks source link

Null reference exception when creating new razor tbb #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new TBB.
2. Select RazorTemplate as the template type
3. Save

When you save, you get a null reference exception. Here's a stack trace. 

StackTrace Information Details:
   at Tridion.Extensions.Mediators.Razor.Templating.RazorTemplateGenerator.ClearWhereUsed(TemplateBuildingBlock template) in c:\code\razorm\razor-mediator-4-tridion-read-only\Tridion.Extensions.Mediators.RazorMediator\Tridion.Extensions.Mediators.RazorMediator\Engine\RazorTemplateGenerator.cs:line 53
   at Tridion.Extensions.Mediators.Razor.RazorHandler.Compile(DateTime revisionDate) in c:\code\razorm\razor-mediator-4-tridion-read-only\Tridion.Extensions.Mediators.RazorMediator\Tridion.Extensions.Mediators.RazorMediator\RazorHandler.cs:line 197
   at Tridion.Extensions.Mediators.Razor.RazorHandler.CompileOnly(DateTime revisionDate) in c:\code\razorm\razor-mediator-4-tridion-read-only\Tridion.Extensions.Mediators.RazorMediator\Tridion.Extensions.Mediators.RazorMediator\RazorHandler.cs:line 173
   at Tridion.Extensions.Mediators.Razor.RazorContentHandler.ValidateCompilation() in c:\code\razorm\razor-mediator-4-tridion-read-only\Tridion.Extensions.Mediators.RazorMediator\Tridion.Extensions.Mediators.RazorMediator\RazorContentHandler.cs:line 137
   at Tridion.Extensions.Mediators.Razor.RazorContentHandler.PerformValidateContent() in c:\code\razorm\razor-mediator-4-tridion-read-only\Tridion.Extensions.Mediators.RazorMediator\Tridion.Extensions.Mediators.RazorMediator\RazorContentHandler.cs:line 127
   at Tridion.ContentManager.Templating.AbstractTemplateContentHandler.ValidateContent()

This points to the ClearWhereUsed function 
https://code.google.com/p/razor-mediator-4-tridion/source/browse/trunk/Tridion.E
xtensions.Mediators.RazorMediator/Tridion.Extensions.Mediators.RazorMediator/Eng
ine/RazorTemplateGenerator.cs#53

Workaround: Save the TBB as a different template type. Open it up again and 
change the template type to RazorTemplate

It seems likely we're trying to read the where-used of an item that doesn't 
exist yet. (It's also possible that this is only reproducible if you have the 
where-used feature configured. I haven't tested that.)

Would a simple null-reference check fix this? 

Original issue reported on code.google.com by dominic....@gmail.com on 12 Nov 2013 at 6:10