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

Apr 11, 2013 at 1:56 PM
Hello,

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.

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

WORKS
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.

http://razorengine.codeplex.com/discussions/248593

Thanks
Apr 11, 2013 at 2:00 PM
Okay, wow, I feel dumb... My model class was private. Making it public fixed my issue.
Sep 16, 2013 at 1: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.