[2005] Serialization and different namespaces
Hi All,
I am trying to perform some simple BINARY serialization for my first time and am having a problem I thought would be easy to solve.
I serialize a simple object to a file on disk, this object is for testing only and contains 2 string member variables - simple.
I can serialize the object just fine but want to de-serialize into a DIFFERENT PROJECT and hence different namespace. When I try to de-serialize the object it get a System.Runtime.Serialization.SerializationException:
Message="Unable to find assembly 'HollyTerm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
How do solve this?
Thanks,
Matt.
Re: [2005] Serialization and different namespaces
How are you serializing/deserializing the object? Should just create a .obj file with the associated XML data. Then this can be loaded into any project that has that type defined, provided that you give it the right location to the file. Does your second project have that same type defined?
Re: [2005] Serialization and different namespaces
Hey Gige!
I am not implementing the ISerializable interface, I am letting .NET do the work for me with a BinaryFormatter.
Yes the second project has the class added to it so that it can be instantiated from the file on disk.
I am not familiar with the .obj file you speak of...
Thanks,
Matt.
Re: [2005] Serialization and different namespaces
hmm well I havent ever messed with binary serialization... I was just referring to using the Xml.Serialization.XmlSerializer class to serialize and deserialize using a streamreader...
Re: [2005] Serialization and different namespaces
Cool cool gige, thanks for the attempt...
Maybe I should have told everyone I was dealing with binary serialization...
Re: [2005] Serialization and different namespaces
Is this for remoting? because the whole idea of remoting is to protect against what you are trying to do...
Re: [2005] Serialization and different namespaces
Dude, that is exactly the question that I just asked in another post...
I dunno if its for remoting, I'm starting to think it is but am having a little trouble getting off the ground, I hadn't heard of remoting until a few hours ago so I'm a little lost.
Check this out:
http://www.vbforums.com/showthread.php?t=444639
Re: [2005] Serialization and different namespaces
OK here is the answer (to the original question)...obvious really, still, it didn't occur to my dim mind.
Create the object in its own solution and compile it to an assembly, include this assembly in both projects and boom, you can serialize and deserialize that object in any namespace.