Developer forum

Forum » Templates » assembly reference missing - upon using generics in Razor Templates

assembly reference missing - upon using generics in Razor Templates

Finn Frost
Reply

Hi All,

I just stumpled upon a issue that might have been mentioned before, but couldn't locate it here on the forum. 

The issue is that suddenly the assembly im using (namespace) couldn't be found i my razor template, i have no idea what triggered it, since the same line worked properly earlier, i tried backtracking/undo some of my work, but couldn't figure out what caused the error. 
I hope anyone here could help me shed some light upon this issue.

An example of what went wrong(caused the template not to be able to be parsed anymore):

I have this line in my template:

System.Collections.Generic.IList<Dynamicweb.Modules.UserManagement.User> users = new System.Collections.Generic.List< Dynamicweb.Modules.UserManagement.User>();

That is the line that caused the error, and said that the assembly dynamicweb could not be found (notice dynamicweb in lowercase).
Also the output displayed on the screen showed this:

System.Collections.Generic.IList<dynamicweb.modules.usermanagement.user> users = new System.Collections.Generic.List<dynamicweb.modules.usermanagement.user>();

It seems that everyting inside the brackets (<>) was lowercased, but couldn't understand why(and still can't). 
Then i remember watching example lines from Dynamicweb (github templates), that had added spaces between the generics brackets, so the line would be like this:

System.Collections.Generic.IList< Dynamicweb.Modules.UserManagement.User > users = new System.Collections.Generic.List< Dynamicweb.Modules.UserManagement.User >();

Notice the space after < and before >. Now the template would parse fine. I spent 45min to 1 hour before i managed to resolve this. 

Hope this post helps other to avoid waisting time upon such an annoying thing. 

Again, if anyone knows why or how this issue can occur, please explain.

 

Thanks in advance


 


Replies

 
Finn Frost
Reply

Well,

It seems the was something on the forum about this issue, notice Mikkel Rickys remarks upon adding spaces in this thread:

http://developer.dynamicweb.com/forum/development/get-path-for-files-directory.aspx

Regarding: Dynamicweb uses Html Agility Pack (HAP) for parsing layout templates and HAP gets confused by some Razor constructs.

Thus the namespace was treated as HTML.

 
Mikkel Ricky
Reply
This post has been marked as an answer

Nice rubber ducking, Finn. By the way, Dynamicweb 8.5 fixes the issues with Html Agility Pack getting confused by and mangling some Razor expressions in layout templates.

Best regards,
Mikkel 

Votes for this answer: 1
 
Finn Frost
Reply

That sounds great Mikkel,

I've just verified, the solution on which i expierenced the issue is running DW 8.4.1.19 - "if only it had been DW 8.5" :).

 

You must be logged in to post in the forum