I get an InvalidCastException when trying to access a property. We have recently upgraded from EPiServer 6 to 7.5, and I suspect this is the cause.
It says it can't cast from string to xhtml string, which I know it can't do, but the problem is where it occurs.
This is the problem line: if(articlePage.MainIntro != null)
So, I set a breakpoint, and tried running articlePage.MainIntro in the Immediate Window, and it threw the exception simply by accessing the property.
Could there be some sort of mismatch between the property type and what is saved in the database?
That sounds like a reasonable cause.
You could go to admin mode and check if that is the cause. Select content type tab find the content type that causes the problem and then click on MainIntro property, there you will se which type it has.
I am not sure if you can change the type of the property from the UI (certain values that comes from code is not editable in admin mode). If not you could temporary comment out the property in code, then go to admin mode and chage the type to the desired one (string => xhtmlstring). Then after saving the value you can add back the property to your model again.
Switching the type of the property in admin worked great.
Thanks for the help!