473,569 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 SystemEnvironme nt 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. SerializationEx ception' occurred in
mscorlib.dll
Additional information: Cannot find the assembly SupportTool,
Version=1.0.201 1.37510, Culture=neutral , PublicKeyToken= null."

Can anyone explain me how can I perform such task?

Thanks!
Tom Rahav.
Jul 22 '05 #1
5 1078
> 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 SerializeFontOb ject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(me m, fnt)
Return Convert.ToBase6 4String(mem.ToA rray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFont Object(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Co nvert.FromBase6 4String(fnt))
Try
Return DirectCast(bf.D eserialize(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******@nospa m.nospam> wrote in message
news:eF******** ******@TK2MSFTN GP10.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 SystemEnvironme nt 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. SerializationEx ception' occurred in
mscorlib.dll
Additional information: Cannot find the assembly SupportTool,
Version=1.0.201 1.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
2045
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, Previous Slide and Home Slide. Is it possible for you to view my page and tell me what I am doing wrong. I have looked at this page for hours and can't...
7
3291
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 buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY...
0
1530
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. If a customer rents several DVDs, every third one of each type is free. You need to tell the user what their total cost of rental whould be based on...
2
1321
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 project and it is running, just not the way it is supposed to. In the "posting guidelines" section it says not to post the whole source code, but that is...
4
1047
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 --------------------------- A Runtime Error has occurred. Do you wish to Debug?
1
1030
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 could really use some help. Thank you in advance. This is what I have: noteFileName=raw_input("What file are the notes in?")...
21
1623
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 frame repaints the menuBar gets painted again under the orignal. Any ideas? public class X2Frame extends JFrame { private JMenuBar menuBar = new...
3
1166
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 the application passes the information that should be equal. i.e 479 ST-Vieurtur as the "Destination" with the call below: if...
0
1242
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 help is appreciated the exact details are below: I'm trying to create an applet that will draw 200 lines all of the same length starting from...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.