![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hello Marc, From your post, my understanding on this issue is: you wonder how to extend a partial class generated with DataSet designer and serialize the properties in the extension. If I'm off base, please feel free to let me know. First, I hope to let you know that our managed newsgroup is focused on break fix issues that are neither urgent, nor complex. If the issue is urgent to your business, it is recommended that you contact Microsoft Customer Support Services (CSS) via telephone so that a dedicated Support Professional can assist you in a more efficient manner. Please be advised that contacting phone support will be a charged call. To obtain the phone numbers for specific technology request please take a look at the web site listed at: http://support.microsoft.com/default...S;PHONENUMBERS. If you are outside the US please see http://support.microsoft.com for regional support phone numbers. According to your description, the class Checklists inherits from global::System.Data.DataSet and is signed with Serializable attribute. As the MSDN article "Object Serialization in .NET" (http://msdn2.microsoft.com/en-us/library/ms973893.aspx) says: Case1: If a class is signed with "[Serializable()]" attribute and does not implement ISerializable interface, the Common Language Runtime (CLR) manages how objects are laid out in memory and the .NET Framework provides an automated serialization mechanism by using reflection. Case 2: If a class is signed with "[Serializable()]" attribute and implements ISerializable interface, it will use the GetObjectData method and a special constructor to serialize or deserialize the object. Because System.Data.DataSet implements ISerializable interface, our situation should fit the case 2. That is to say, .NET framework will use the GetObjectData method and the deserialization contructor to serialize/deserialize the object. In your post, you extend the Checklists class by adding another partial class. Because the properties var1, var2 in the extension are not added into GetObjectData and the special constructor which is generated by the designer, they will be lost when we try to serialize or deserialize them. Here are several approaches to workaround it: #1. As you said, we can make a derived class in which we override the GetObjectData() and the desrialization contructor. #2. We can add a wrapper class for Checklists. That is to say, we could create a class and add Checklists object, var1, var2 as its properties. Then we claim the class as Serializable and implements ISerializable interface. Var1, var2 and the Checklists object are serialized/deserialized respectively in GetObjectData and the special constructor. For instance: public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("var1", var1); info.AddValue("var2", var2); info.AddValue("Checklists", checklists, typeof(checklists)); } For more information about .net Serialization, you may refer to Jeffrey Richter's three articles in MSDN Magazine: http://msdn.microsoft.com/msdnmag/issues/02/04/net/ http://msdn.microsoft.com/msdnmag/is...t/default.aspx http://msdn.microsoft.com/msdnmag/issues/02/09/net/ Please let me know if you have any other concerns, or need anything else. Sincerely, Jialiang Ge (jialge (AT) online (DOT) microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== For MSDN subscribers whose posts are left unanswered, please check this document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif ications. If you are using Outlook Express/Windows Mail, please make sure you clear the check box "Tools/Options/Read: Get 300 headers at a time" to see your reply promptly. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
#8
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |