?
Solved

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

Posted on 2014-11-25
2
Medium Priority
?
103 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

770 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