Vibrant discussion about CSLA .NET and using the framework to build great business applications.
Review post below.
It may assist you. Its using NVL objects not new class, but does use different code in DataPortal_Fetch
I don't know. I don't think we specifically tested using enum values through the MobileFormatter. I've entered a bug so this question/issue doesn't get lost.
I guess I should ask a clarifying question though.
Are you saying
I could see 1, as that's what we didn't test (I don't think).
If the problem is 2, then that's almost certainly a bug in your code, because I know NVL objects serialize just fine - I use them all the time.
If the problem is 3, then we need to talk about how you created the custom object. The MobileFormatter has very strict requirements around what objects it will and won't serialize, and if you want to pass any custom object through the data portal you have to create the object exactly right. CSLA has base classes you should inherit from, but the easiest solution, by far, is to use one of the normal business object base classes with managed backing fields - otherwise you'll have to do some extra work.
Thanks for the detailed explanation, that helps a lot.
Hopefully we can figure out a solution. The process of serializing values to/from Silverlight and .NET is complex because they are two different platforms, so there are no common types between them. Even what we see as the "same type" is actually not the same type at all...
I'm just wondering what the final outcome of this was?
I see the 'bug' is closed as resolved, however when I try and use enums in a Silverlight/.Net mixed environment, I still receive the serialize error.
Is there an attribute i need to set on the enum to make this work???
It sure looks like the fix was applied in April 2009:
Based on the code, I can't see how a special attribute or anything would be required - the serializer is just locating anything of type enum and is converting it to the underlying type.
Thanks for the awesomely quick reply!
I've looked through all your CSLA light samples, and I can't see anywhere at all that you have ever used an enum as property type.
I've already converted all my PropertyInfo to now use <int>, but I'll make up a quick project later today to get the exact error that occurs. (It was a few hours ago, and my memory doesn't span that far back ;-).)
Will post here later today.
There's a unit test for this: BusinessObjectWithEnum() in the Silverlight serialization tests.
Just wanted to mention that I am using the latest and I seem to be having an issue with enums as well. Using the very latest CSLA.
Type '<mytype>' with data contract name '<enumtype>:http://schemas.datacontract.org/2004/07/<ns>' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
I'm just going to use an integer for the property as I know that works, but just thought I'd mention this too.