Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 24, 2009 04:38 AM by maxi_ng
Dec 23, 2009 09:42 AM|LINK
I can get everything work if I am using ProfileBase
Profile.SetPropertyValue() and Profile.GetPropertyValue().
But if I inherit the ProfileBase to make a strongly-typed class and return it to the page like this
protected CustomProfile Profile
It will give me an invalid cast exception.
What should I do? no one mention this exception when they implement like this.
Dec 23, 2009 11:38 AM|LINK
It seems I am retarding on innovations,
but I always though that property
is just a fancy parallel methods to a private
member declared outside.
Where is in your code declaration of a member
being returned and stored inside?
What is the text of error and the line where it is thrown?
Can you provide more code?
Dec 24, 2009 01:00 AM|LINK
Sometimes the same thought comes to my mind too, fancy private ..., I agree.
Well, I want to have strongly typed so that my fellow programmers don't have to check if that attribute are actually there and the spelling must be correct.
The line throwing the error is inside the BasePage InitializeCulture(), I am trying to add that to every Page Class.
string l_userLanguage = Profile.LanguagePreference; //this one access Profile and it throw cast exception from ProfileCommon
This implementation are invented by others, I read it from some blog posts. They don't have this problem.
They said WAP don't even generate ProfileCommon. But I think my WAP is generating it.
My CustomProfile inherit from ProfileBase and the auto generated ProfileCommon also inherit ProfileBase.
So I think that invalid cast make sense since they are sibling, But what should I do not??
I think I will try wrapping my own ProfileCommon too for instance. Come back to you if I got lucky.
Dec 24, 2009 01:09 AM|LINK
I think I read somewhere said that if the user is not logged in.
Null profile will becomes ProfileCommon instead of my CustomProfile.
I am looking into that.
Dec 24, 2009 04:38 AM|LINK
I worked it out.
It has a casting problem because I put my source in App_Code in WAP.
moving them out solve the problem. But how that happen remains mystery.