|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Deserialization type load exception even when using a serialization binderI 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 Are you sure your BindToType is getting the new type from the correct
assembly? It might help to see the code. <john_smith_***@hotmail.com> ha scritto nel messaggio Show quote news:1170193929.977574.320360@v33g2000cwv.googlegroups.com... > 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 > 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. Show quote On Jan 31, 11:28 am, "Laura T." <L***@NOWHERE.COM> wrote: > Are you sure your BindToType is getting the new type from the correct > assembly? > It might help to see the code. > > <john_smith_***@hotmail.com> ha scritto nel messaggionews:1170193929.977574.320***@v33g2000cwv.googlegroups.com... > > > 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 |
|||||||||||||||||||||||