This project is read-only.

'object' does not contain a definition for 'Header'

Apr 11, 2013 at 2:56 PM

I'm getting this error when parsing my template even though my model object does have the Header property on it. The odd thing is if I use and anonymous type it works fine. Any ideas how I can fix this? I'm using .NET 4.0.

string body = Razor.Parse<EmailBodyModel>(template, model);

string body = Razor.Parse(template, new { Header = "xxx"} );

I came accross the discussion below but that appears to be the opposite issue that I have.

Apr 11, 2013 at 3:00 PM
Okay, wow, I feel dumb... My model class was private. Making it public fixed my issue.
Sep 16, 2013 at 2:38 PM
Did the same thing as well :roll:

Maybe if this exception is thrown the Parse method should test the objects protection level and throw a nicer error if it is private / internal.