Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Implementing a serialization formatter

Posted on 2003-11-06
4
Medium Priority
?
497 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

610 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