Results 1 to 8 of 8

Thread: [2005] Serialization and different namespaces

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    [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.
    Last edited by GottaGetITDone; Dec 26th, 2006 at 09:42 PM. Reason: Overlooked important details...

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    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.

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    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...

  6. #6
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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...

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    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

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width