.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > Binary Serialization problem with type conversion
 

Binary Serialization problem with type conversion

I'm saving a fairly large object graph to a file using then binary formatter.

When I try to read it back in a different .net application I get a

$exception{"Unable to cast object of type "Namespace.Project' to type 'Namespace.Project'."}System.Exception {System.InvalidCastException}

I'm using

private static void LoadReactorAssm()

{

AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);

}

static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args)

{

Assembly a = null;

string serializationAssemblyPartialName = "AseemblyName";

if (args.Name.IndexOf(serializationAssemblyPartialName) != -1)

{

string sSerializersDLL = "AseemblyName.exe";

string smartDeploymentHostLocation = @"c:\appdir\";

a = Assembly.LoadFrom(smartDeploymentHostLocation + sSerializersDLL);

}

return a;

}

to load the assembly in.

LittleRascal

OK I figured it out.

For the record, you basically can't do this for the simple reason that a type includes the assembly name in it.

The solution is to put the serializable stuff in a .dll and call it from there from both applications.

LittleRascal

I guess what I'm asking is

If I have an application called Billwith a class of type Apple and I have another application called Ben with the same class in it, how can I serialize the Apple in Bill and deserialize it in Ben.

Is that possible or should I be using SOAP?

If so, thats a problem because I have a ton of generics...

LittleRascal

OK I figured it out.

For the record, you basically can't do this for the simple reason that a type includes the assembly name in it.

The solution is to put the serializable stuff in a .dll and call it from there from both applications.

LittleRascal

You can use google to search for other answers

Custom Search

More Threads

• Problem in Automatic Deserialization of Low typeFilterLevel
• Singlecall or Singleton. please suggest
• Identification of Constructor being called
• Unable to make remote call from server to clients on XP Machines
• Binary serialization and the Decimal type.
• need help with inheriting 'System.MarshalByRefObject' for remoting
• My remoting application work on XP but does not work on Windows Server 2003
• ??? Getting started with remoting ???
• Always inherit from MarshalByRefObject?
• How to use Microsoft Official Curriculum?