?
Solved

Implementing a serialization formatter

Posted on 2003-11-06
4
Medium Priority
?
494 Views
Last Modified: 2008-02-01
Hi,

I am trying to implement my own formatter that implements and adheres to the standards of the IFormatter interface. I have run into a bit of an issue trying to serialize classes that implement the ISerializable interface. Specifically, I don't know how to repopulate the members (via the special New constructor). The MSDN documentation for the FormatterServices.PopulateObjectMembers function claims that:

"if the object implements ISerializable, the populating is handed off to the object itself. If a matching surrogate is not found, and the object does not implement the ISerializable interface, then deserialization populates each field listed in members, with the corresponding value listed in data."

Based on this, I figure I need to call this method to populate the data for classes that implement ISerializable. What I can't figure out is what to pass for the "members()" parameter. It expects an array of MemberInfo objects, but I can't construct those, the constructor is protected. I even tried to create my own class that inherits from MemberInfo, but it just threw an error when I passed it in saying:

"An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: Only FieldInfo, PropertyInfo, and SerializationMemberInfo are recognized."

Does anyone have any ideas as to how I can get around this? Does anyone know what a SerializationMemberInfo is?

Thanks,
Zaphod.
0
Comment
Question by:Z_Beeblebrox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:NetPointer
ID: 9703098
This might help u...
http://www.c-sharpcenter.com/InsideDotNet/IDN_CustomSerial.asp


Regards,
NetPointer
0
 
LVL 7

Author Comment

by:Z_Beeblebrox
ID: 9703168
Hi,

Thanks for the link, but unfortunately it discusses how to make a class that implements ISerializable, not how to make a class that calls a class that implements ISerializable.

Zaphod.
0
 
LVL 7

Accepted Solution

by:
Z_Beeblebrox earned 0 total points
ID: 9804703
I figured out one way to do this. What you can do is add the structure to an instance of the System.Runtime.Serialization.ObjectManager with its associated SerializationInfo. Then when you call DoFixups on the ObjectManager, it will call the constructor.

Zaphod.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question