Developer forum

Forum » Development » Error in Template after newest update

Error in Template after newest update


Reply

After the newest update I get an error in one of our solutions:

 


System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Template.Template(String& strTemplatePath) at Dynamicweb.Template..ctor(String strTemplatePath) at FonqiHelp.FonqiControls.RentaMenu()

The code that produces the error is this:

 

public static string CreateMenu()
{
    try
    {
        Template t = new Template("RentAMenu.html");
        return t.Output;
    }
    catch (Exception ex)
    {
        return "Menu not generated " + ex.ToString();
    }
}

 

the Html file is a plain html file with no scripts or nothing spectacular about it.

 

Is something changed in the way the Dynamic Template class loads a template by Filename?

or what could the error be?

 

*The solution started failing after the latest DW update.

 

kind regards Sune Fengel


Replies

 
Reply

I have to check up on that.

 

But you might consider converting it to using the TemplateV2 object instead?

 
Reply

 

Ok Ill do that from now on but it should not crash all my old solutions where I use the TemplateV1 object. (and it doesnt appear to do so the places where i checked).

 

- Sune

 
Reply

No, it seems pretty weird that it happens in only one solution. But the code you provided tells the template object to load the file from the Templates folder. Is this the correct location for the file?

 

One thing, though. Are there any differences in the request context of the page that fails and those that don't? Could you spot a pattern here?

 
Reply

Well it could be the only place where i call it with a static method.

another thing that could be the issue is if the html document is damaged in some way or access rights are set to not read or whatever.

 

but the strange thing is that it worked fine until DW rolled out the new updated DLL's.

 

- Sune

 
Reply

I got an other reporting on this issue this morning in a project where templates are used in backend. Do you also get the error in backend?

 
Nicolai Høeg Pedersen
Reply

Hi Sune

 

The error is located. I've mailed you an updated Dynamicweb.dll with a fix. When the fix has been validated to solve the errors it will be released with a DW hotfix.

 
Reply

Great thanks a lot.

- Sune

 

You must be logged in to post in the forum