Consider the following simple class:
<Serializable() > _
Public Class SimpleClass
Private m_AString As String
Private m_AByteArray As Byte()
Public Property AString() As String
. . .
End Property
Public Property AByteArray() As Byte()
. . .
End Property
End Class
I can use xml serialization to serialize an instance of this class to a
file. Works fine. Now I want to make it a little more complex like the
following two classes:
<Serializable() > _
Public Class DataFile
Private m_FileName As String
Private m_FileData As Byte()
Public Property FileName() As String
. . .
End Property
Public Property FileData() As Byte()
. . .
End Property
End Class
<Serializable() > _
Public Class ComplexClass
Private m_AString As String
'An array of DataFile objects
Private m_aDataFiles As DataFile()
Public Property AString() As String
. . .
End Property
Public Property DataFiles() As DataFile()
. . .
End Property
End Class
When I try to serialize an instance of the ComplexClass, I get an
exception:
"There was an exception reflecting type 'Complex Class'
Here is the code I use to serialize the object. The exception occurs on
the line indicated:
Private Sub Button1_Click(. ..) Handles Button1.Click
Dim oTest As New ComplexClass
oTest.AString = "One"
ReDim oTest.DataFiles (1)
oTest.DataFiles (0) = New DataFile("c:\te st\testme.en.wa v")
oTest.DataFiles (1) = New DataFile("c:\te st\my recording.en.wa v")
Dim fs As New FileStream("c:\ Complex.xml", FileMode.Create )
'**** ERROR OCCURS ON FOLLOWING LINE ****
Dim xs As New XmlSerializer(G etType(ComplexC lass))
xs.Serialize(fs , oTest)
End Sub
Is it possible to do what I want?
Thanks,
--
Chris
dunawayc[AT]sbcglobal_lunch meat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address. 1 1183
On Thu, 18 Nov 2004 14:47:10 -0600, Chris Dunaway wrote: Is it possible to do what I want?
Wouldn't you know it? Shortly after I submitted this question, I found the
answer. By digging into the stack trace, it turns out that the classes
involved must have a default parameterless constructor, which I did not
have in my test. Once I added that, it worked like a charm.
--
Chris
dunawayc[AT]sbcglobal_lunch meat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin. D. Waller |
last post by:
Hello,
Does anyone kow of any good examples or documents that talk about
serializing complex objects and object graphs to XML. Basically I would like
to have a class that references other classes etc and I'd like to serialize
the whole thing...
Many thanks...
Martin
|
by: Ivo Bronsveld |
last post by:
All,
I have quite a challenging task ahead of me. I need to write an object model
(for code access) based on a schema, which cannot be made into a dataset
because of it's complexity.
So I created a couple of objects and serializing it into XML based upon the
schema works perfectly.
The XML / Schema looks something like this:
|
by: Tobias Zimmergren |
last post by:
Hi, just wondering what serializing really is, and howto use it?
Thanks.
Tobias
__________________________________________________________________ Tobias
ICQ#: 55986339 Current ICQ status: + More ways to contact me
__________________________________________________________________
|
by: Joe |
last post by:
Hello All:
Say I have a solution with two projects (Project1 and Project2) and each
project contains a class (Project1 contains Class1 and Project2 contains
Class2).
The projects don't reference each other. Here's my question: can I
serialize Class1 and use the serialized XML in Class2? How would Class2
de-serialize the XML to retrieve the Class1's properties? I don't see how I
can do this since Project2 doesn't even know about...
|
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
| |
by: JEB |
last post by:
I have an object that wrote the serialization for to use with Remoting and
now I would like to use it with Web Services. The object consist of a short
and a string value (lets call it Item). This object is then contained in an
array that constains at string (lets call it Column). Then this object is
stored in an array as well (lets call it Row). So, I have the following
setup:
(The Hierarchy)
Row
--> Column
|
by: Charles Law |
last post by:
I have a complex object that I am serializing, and I would like to omit
elements that have a default value.
For example, if I have a class as follows
Public Class Test
Private m_Name As String = "George"
Private m_Active As Boolean = False
Private m_Address As String
|
by: Max |
last post by:
Due to the behaviour of a particular COM object, I need to ensure that a
request for a particular ASP page is finalized before another request for
the page is processed. Does IIS have a way to ensure that subsequent
requests will be queued until the current request is completed?
If not, can IIS be configured to use seperate processes to satisfy requests
for a nominated ASP page?
Thanks in advance.
|
by: |
last post by:
I've got a basic "chat" infrastructure that can send objects across the wire, but I'm running into a few issues with trying to send multiple messages and things behaving differently in debug and release...
Is there anyone out there that considers themselves a threading / sockets / serialization guru? Not sure if it's appropriate to post an entire project here and the issues discussion is probably a bit too complex for newsgroup back and...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |