473,390 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Need some help with serialization please

Hello All!

I want to store some information about application's evrironment, such as
allowed modules, application's paths, etc. For this purrpose, I created a
class called SystemEnvironment that contains all the variables I need to
store, and methods for serialization and deserialization the object.
What I want to do is to create an object with all the values I want and
serialize it into a binary file, and to this in one application called
SupportTool.
Then, I want to copy the binary file into a different application's folder
and deserialize the object into the new application, so it can get the
pre-configured preferences I set in the SupportTool.
When I tried to do so, everything went well till I tried to deserializie the
object into the new application (that contains the exact class as the
SupportTool). I got the following error message:

"An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
mscorlib.dll
Additional information: Cannot find the assembly SupportTool,
Version=1.0.2011.37510, Culture=neutral, PublicKeyToken=null."

Can anyone explain me how can I perform such task?

Thanks!
Tom Rahav.
Jul 22 '05 #1
5 1071
> object into the new application (that contains the exact class as the
SupportTool). I got the following error message:


What does this mean? I suspect that you added the same code to both
projects. Even though the code is the same, the types are completely
different and they cannot (de)serialize one another.

Your best bet would be to place the class you wish to (de)serialize
into its own Class Library and then reference the resultant .dll from
both project. That will ensure that the types are the same.

Jul 22 '05 #2
> object into the new application (that contains the exact class as the
SupportTool).


Does this mean that you have referenced a .dll that contains the exact
class or merely added the class .vb file into the second project? If
you just added the .vb file to the second project, you are not using
the same class. It is a completely different type, even though the
code is the same.

Your best bet is to place the class you want to (de)serialize into its
own Class Library and then reference it from both projects. That will
insure that you are (de)serializing the *same* type.

Jul 22 '05 #3
Tom,

You can try this sample from Tom Shelton

(Assuming that you have set the serializable tag)

\\\
Private Function SerializeFontObject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(mem, fnt)
Return Convert.ToBase64String(mem.ToArray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFontObject(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Convert.FromBase64String(fnt))
Try
Return DirectCast(bf.Deserialize(mem), Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function
///

I hope this helps a little bit?

Cor
Jul 22 '05 #4
Sorry for the duplicate post. Google Groups displayed an error the
first time I submitted my post so I didn't think it got through.

Jul 22 '05 #5
Hi!
Thank you very much for your help!!
I created a new .dll file contains the class I need, added it into both
projects and it works PERFECT!
Thanks alot again for your help!
Tom.

"Tom Rahav" <to******@nospam.nospam> wrote in message
news:eF**************@TK2MSFTNGP10.phx.gbl...
Hello All!

I want to store some information about application's evrironment, such as
allowed modules, application's paths, etc. For this purrpose, I created a
class called SystemEnvironment that contains all the variables I need to
store, and methods for serialization and deserialization the object.
What I want to do is to create an object with all the values I want and
serialize it into a binary file, and to this in one application called
SupportTool.
Then, I want to copy the binary file into a different application's folder
and deserialize the object into the new application, so it can get the
pre-configured preferences I set in the SupportTool.
When I tried to do so, everything went well till I tried to deserializie
the object into the new application (that contains the exact class as the
SupportTool). I got the following error message:

"An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
mscorlib.dll
Additional information: Cannot find the assembly SupportTool,
Version=1.0.2011.37510, Culture=neutral, PublicKeyToken=null."

Can anyone explain me how can I perform such task?

Thanks!
Tom Rahav.

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TrvlOrm | last post by:
HI There, I have been struggling with JavaScript code for days now, and this is my last resort! Please help... I am trying to create a JavaScript slide show with links for Next Slide,...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
0
by: tgregg6 | last post by:
I need help with my problem I am stuck and I don't know what to do!!! The problem is: This program calculates the charges for DVD rentals where current releases cost $3.5 and all others cast $2.50....
2
by: Dalton | last post by:
This is all kind of in another language to, I mean I understand most of the words in relation to programming, but my field of work/study is IT. Anyways, on to the problem. I am working on my 5th...
4
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a simple user control that has a button on it which is on my web page. everytime i click it i get the following message: --------------------------- Error...
1
by: lchristy0213 | last post by:
I just started programming and I'm trying to get python to read a txt file and then turn the letters in the file into notes with certain frequencies, and then create a wav file. I'm doing ok but...
21
by: SpecialKay | last post by:
i have a menu bar, when i run the code the first time everything is fine. If i click on the screen i print a Circle or a Square, store the shape in an arraylist and repaint the frame. When the...
3
by: DragonLord | last post by:
Here is the situation I am inserting rows into a datagridview and then using a function to group similar rows together based on a column. When I call to compare the lastrow with the current row...
0
by: danielmessick | last post by:
Hey all !! I'm having a frustrating time trying to create a particular Java applet for a class.. I have no clue how to accomplish this, and really need HELP.. Anyone, PLEASE help me if you can, any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.