Solved

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

Posted on 2014-11-25
2
102 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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