Solved

How can I Serialize an object in one project and De-Serialize it in another?

Posted on 2014-11-25
2
101 Views
Last Modified: 2014-12-02
Hello,

In order to save certain program settings, I created an object, and added the <Serializable()> tag to it.  Then in my code, I can save those settings using code like:

        Dim saveFile As New FileStream(ExportFile_PathName, FileMode.Create, FileAccess.Write, FileShare.None)

        Dim formatter As New BinaryFormatter
        formatter.Serialize(saveFile, Settings)

        saveFile.Close()


and load them using code like:


               readFile = File.OpenRead(SettingsFile_PathName)

                Dim BFormatter As BinaryFormatter
                BFormatter = New BinaryFormatter

                Settings = New clsCattle_Settings(CType(BFormatter.Deserialize(readFile), clsCattle_Settings))


                readFile.Close()


This works perfectly when all of the code for saving and loading these serialized files is within the same program.  However, what I would like to do is create a different program to create those settings files than the one that will be loading them.  When I tried to do this, though, the program that is loading the file does not recognize the file format.  So clearly there is some kind of meta-data in the serialized file stating where the object being serialized was created, and the BinaryFormatter in Program B cannot convert the class serialized in Program A to the same type of class.

So is there a way to get around this?  Thank you.

Vijay
0
Comment
Question by:vdurbal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40465422
You need to create a common library that both projects share. Place the settings class in that library. Then you should be able to (de)serialize across those boundaries.
0
 

Author Closing Comment

by:vdurbal
ID: 40476565
I'll try that.  Thanks!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question