Re: Deserialization type load exception even when using a serialization binder

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



It turns out that one of the saved objects had an instance field of
system.type that points to one of the old types. That's why it wasn't
going through the serialization binder.

Thanks for you help.

On Jan 31, 11:28 am, "Laura T." <L...@xxxxxxxxxxx> wrote:
Are you sure your BindToType is getting the new type from the correct
assembly?
It might help to see the code.

<john_smith_...@xxxxxxxxxxx> ha scritto nel messaggionews:1170193929.977574.320360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi,

I moved some code from my project to a separate assembly. I have some
saved definitions that were saved using regular .net serialization.
When trying to open the saved definitions, I get type load
exceptions. I am getting around this by implementing my own
SerializationBinder and forwarding the typenames to the new assembly.
I successfully forward all the types but yet I still get a type load
exception later on in the deserialization. It seems the formatter is
still referencing the old type name instead of the forwarded one. I
should also mention that the type that generates the error is a
parameter to another type which is generic. I can't think of a way
around this and so I can't open any saved definitions right now. I'm
hoping one of you guys knows a solution.

Here's the stack trace of the framework part of the exception:
at System.Reflection.Assembly.GetType(String name, Boolean
throwOnError, Boolean ignoreCase)
at System.UnitySerializationHolder.GetRealObject(StreamingContext
context)
at
System.Runtime.Serialization.ObjectManager.ResolveObjectReference(Objec
tHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize
(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck,
Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserial
ize(Stream serializationStream, HeaderHandler handler, Boolean fCheck,
Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserial
ize(Stream serializationStream)

Thanks


.



Relevant Pages

  • Re: XmlSerialization is failing due to a circular reference.
    ... XML serialization does not support circular references. ... xmlWriter, Object o, XmlSerializerNamespaces namespaces, String ... n, String ns, ManagementGroup o, Boolean isNullable, Boolean needType) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TrueClass/FalseClass vs. Boolean
    ... }>> when Boolean ... } door open for duck typing. ... do XML-RPC serialization (yes, I know there is XML-RPC support in the ...
    (comp.lang.ruby)
  • Deserialization type load exception even when using a serialization binder
    ... saved definitions that were saved using regular .net serialization. ... Here's the stack trace of the framework part of the exception: ... at System.Reflection.Assembly.GetType(String name, Boolean ... ize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, ...
    (microsoft.public.dotnet.framework)