问题
I am writing a library which is a set of classes meant to be shared between many different .NET applications, including at least one which uses the .NET compact framework. I have been making these classes use the [DataContract] attribute with a bunch of [DataMember]s so that they are easy to serialize and deserialize using the DataContractJSONSerializer. I have been searching the web to try to find out if this functionality (DataContractAttribute, DataMemberAttribute, and DataContractJsonSerializer) is supported in the .NET Compact Framework 3.5 but I have had no luck even being able to find a full list of supported classes in the .NET Framework.
Does anyone happen to know the extent of support for these functions?
回答1:
I believe that System.Runtime.Serialization namespace exists in .net 3.5 CE. Here is complete list of namespaces, but it looks like any of functionalities you are interested are not supported within it.
As I understood you are trying to create some entities library which can be serialized. I think you need to have another approach for your .net CE application. Say different library (or same code but compiled for ce with directives defined). Then you would need to utilize some external library for json serialization (if you still need it).
Also think about using another serialization mechanism instead of DataContractJsonSerializer. Start with another good question here at SO.
If you are trying to work with some services, there is post on msdn forum, where similar issue discussed. What they propose is to have some middle tier.
Anyway whatever you do with .NET 3.5 CE is going to be hard as, honestly, it is an outdated technology.
来源:https://stackoverflow.com/questions/10049863/does-the-compact-framework-3-5-support-system-runtime-serialization