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

Home Posts Topics Members FAQ

Serialize Structure

I would like to serialize a custom structure eg.

Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas As ArrayList
End Structure

I am using a BinaryFormatter () to serialize the data. Each Dog is added to a
HashTable, and then the final HashTable is serialized... well that is the
intention.
Why does it come up with following error : PublicKeyToken= null' is not
marked as serializable

Any help on achieving this task or pointers would be helpful
Scott
Jun 16 '06 #1
2 1838
Try adding the SerializableAtt ribute to the structure:
<Serializable() >
Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas as ArrayList
End Structure

You can mark individual fields as un-serializable with the
NotSerializable Attribute.
--
http://www.peterRitchie.com/
"Scott Collier" wrote:
I would like to serialize a custom structure eg.

Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas As ArrayList
End Structure

I am using a BinaryFormatter () to serialize the data. Each Dog is added to a
HashTable, and then the final HashTable is serialized... well that is the
intention.
Why does it come up with following error : PublicKeyToken= null' is not
marked as serializable

Any help on achieving this task or pointers would be helpful
Scott

Jun 16 '06 #2
Thanks Peter, I didn't think it was going to be that easy - but it worked.

Scott
"Peter Ritchie" <PR****@newsgro ups.nospam> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
Try adding the SerializableAtt ribute to the structure:
<Serializable() >
Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas as ArrayList
End Structure

You can mark individual fields as un-serializable with the
NotSerializable Attribute.
--
http://www.peterRitchie.com/
"Scott Collier" wrote:
I would like to serialize a custom structure eg.

Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas As ArrayList
End Structure

I am using a BinaryFormatter () to serialize the data. Each Dog is added
to a
HashTable, and then the final HashTable is serialized... well that is the
intention.
Why does it come up with following error : PublicKeyToken= null' is not
marked as serializable

Any help on achieving this task or pointers would be helpful
Scott

Jun 17 '06 #3

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

Similar topics

5
4778
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e. "payload") using pointers. Examples of these are binary trees, hash tables etc. Thus, the message itself contains only a pointer to the actual data....
14
14284
by: vince | last post by:
Can I add (append) to an xml file that already contains a serialized object, and be able to deserialize to either or both objects from the same file...??? How is this done...?? thanks, vince
3
10376
by: MAY | last post by:
Hi, I have a problem about serialize the form controls. I wrote a test program to test serialize a from but fail (->An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll) . Thx in advance. Here is the part of the code: Regards MAY
3
10802
by: ~~~ .NET Ed ~~~ | last post by:
Hello, I am having a problem trying to serialize this simple structure, I use it in a collection class that derives from CollectionBase but I noticed that at least for now the serialization exception ocurrs when i try to serialize this structure (see below). The idea is that it would be serialized to: < Param type="..." method="Get"...
5
2366
by: objectref | last post by:
Hi to all, let's say i have a form with 2 buttons and 3 textboxes on it. Is there a way to Serialize the form so when i de-Serialize and cast it to a Form, i will get back the original form with the textboxes filled with their original values ?? I have built an app that i want to have the values of many-many forms' controls on the disk...
2
1601
by: Dennis | last post by:
Does anyone know why this code gives an error: <serializeable> public structure TestSerialize anumber as integer astring as string end strucuture Dim t As TestSerialize Dim formatter As New BinaryFormatter Dim s As New MemoryStream
10
4014
by: Uma - Chellasoft | last post by:
Hai, I am new to VB.Net programming, directly doing socket programming. In C, I will be able to map the message arrived in a socket directly to a structure. Is this possible in VB.Net. Can anyone please help me with some sample codings and guidance? Can you also suggest some other news group available for socket programming in VB.Net?
4
2246
by: teddysnips | last post by:
I would like to serialize a class to XML. The format of the XML is fixed (see below). It only needs to be serialized - it is read by another application. I know I can do it manually using XMLTextWriter - e.g. Dim xwriter = New XmlTextWriter("C:\Projects\Formflo\WindowsService\NDde\test.xml", System.Text.Encoding.UTF8)...
5
3778
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);" I thought that it is very hard to memory map structure array. I need both read and write memory mapped file at both side of C# and C++.
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
7926
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...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
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...
1
2117
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
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.