I'm trying to write a preferences-handling infrastructure that
serializes prefs to XML. Basically I want to read in a common
"default" prefs set, then read in the user's prefs and override the
defaults as appropriate. I'm trying to do them both using the
SoapFormatter to [de]serialize. But when I try to read in the user's
prefs after reading the defaults, both from similar Soap files, I get
this exception:
----
System.Runtime.Serialization.SerializationExceptio n: An object cannot
be registered twice.
at System.Runtime.Serialization.ObjectManager.Registe rObject(Object
obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj,
MemberInfo member, Int32[] arrayIndex)
at System.Runtime.Serialization.Formatters.Soap.Objec tReader.RegisterObject(Object
obj, ParseRecord pr, ParseRecord objectPr)
at System.Runtime.Serialization.Formatters.Soap.Objec tReader.ParseString(ParseRecord
pr, ParseRecord parentPr)
at System.Runtime.Serialization.Formatters.Soap.Objec tReader.ParseArrayMember(ParseRecord
pr)
at System.Runtime.Serialization.Formatters.Soap.Objec tReader.ParseMember(ParseRecord
pr)
at System.Runtime.Serialization.Formatters.Soap.Objec tReader.Parse(ParseRecord
pr)
at System.Runtime.Serialization.Formatters.Soap.SoapH andler.EndElement(String
prefix, String name, String urn)
at System.Runtime.Serialization.Formatters.Soap.SoapP arser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapP arser.Run()
at System.Runtime.Serialization.Formatters.Soap.Objec tReader.Deserialize(HeaderHandler
handler, ISerParser serParser)
at System.Runtime.Serialization.Formatters.Soap.SoapF ormatter.Deserialize(Stream
serializationStream, HeaderHandler handler)
at System.Runtime.Serialization.Formatters.Soap.SoapF ormatter.Deserialize(Stream
serializationStream)
at <my code>
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
------
<this last line might be unrelated>
Can anyone give me some pointers to help? I can't see why loading in
the same class twice from two separate Soap files would be
illegitimate. Is there any way to override this "class registration"
step the second time, or to allow the 2nd registration to override the
first?
Thanks,
Philip