473,320 Members | 1,904 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,320 software developers and data experts.

Serializing an object.

I'm trying to serialize an object in VB.NET. I have all my objects denoted
with the <Seralizable()> Attribute. This is the code I am using...

Dim sf As SoapFormatter = New SoapFormatter

Dim ms As IO.MemoryStream = New IO.MemoryStream

sf.Serialize(ms, currentIssue)

ErrorReportingTextBox.Text &= vbCrLf &
Convert.ToString(Convert.ToBase64String(ms.ToArray ).ToString)

I get a list of a whole bunch of strange letters. So, I know I'm doing this
wrong, but I just want a simple serialization. I'd prefer to not have any
SOAP envelopes and such in the data (This is the only sample I could find)

Thanks in Advance

Scott
Nov 12 '05 #1
2 3090
The Convert.ToBase64String encodes an array of (potentially) binary data
into an ASCII text compatble format so you can transmit binary data inside a
text file. I don't think that's what you. It seems like you just want to
write out the result of the serialization. Try this instead:

ms.Position = 0

ErrorReportingTextBox.Text &= vbCrLf & New StreamReader( ms ).ReadToEnd()

You will have to strip the Soap related markup if you serialize with the
SoapFormatter. Take a look at [0] for some more background information.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I'm trying to serialize an object in VB.NET. I have all my objects denoted with the <Seralizable()> Attribute. This is the code I am using...

Dim sf As SoapFormatter = New SoapFormatter

Dim ms As IO.MemoryStream = New IO.MemoryStream

sf.Serialize(ms, currentIssue)

ErrorReportingTextBox.Text &= vbCrLf &
Convert.ToString(Convert.ToBase64String(ms.ToArray ).ToString)

I get a list of a whole bunch of strange letters. So, I know I'm doing this wrong, but I just want a simple serialization. I'd prefer to not have any
SOAP envelopes and such in the data (This is the only sample I could find)

Thanks in Advance

Scott

Nov 12 '05 #2
Awesome, thanks!

EXACTLY what I needed.

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:uG**************@TK2MSFTNGP10.phx.gbl...
The Convert.ToBase64String encodes an array of (potentially) binary data
into an ASCII text compatble format so you can transmit binary data inside a text file. I don't think that's what you. It seems like you just want to
write out the result of the serialization. Try this instead:

ms.Position = 0

ErrorReportingTextBox.Text &= vbCrLf & New StreamReader( ms ).ReadToEnd()

You will have to strip the Soap related markup if you serialize with the
SoapFormatter. Take a look at [0] for some more background information.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I'm trying to serialize an object in VB.NET. I have all my objects

denoted
with the <Seralizable()> Attribute. This is the code I am using...

Dim sf As SoapFormatter = New SoapFormatter

Dim ms As IO.MemoryStream = New IO.MemoryStream

sf.Serialize(ms, currentIssue)

ErrorReportingTextBox.Text &= vbCrLf &
Convert.ToString(Convert.ToBase64String(ms.ToArray ).ToString)

I get a list of a whole bunch of strange letters. So, I know I'm doing

this
wrong, but I just want a simple serialization. I'd prefer to not have any SOAP envelopes and such in the data (This is the only sample I could find)
Thanks in Advance

Scott


Nov 12 '05 #3

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

Similar topics

0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
1
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...
6
by: Rein Petersen | last post by:
Hi Folks! Here's a strange behaviour: Without a properties SET accessor (see code below), the property will not serialize. public class myObject {
1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
2
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: +...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
4
by: Jason Shohet | last post by:
We are thinking of serializing an object & passing it toseveral functions on web service. This will happen about 35 times as the page loads. The class has about 20 attributes. We're not sure...
3
by: axr | last post by:
Having trouble with Serilization of objects that contain members which are of type Interface eg public class SomeClass { ISomeInterface1 itf1; ClassType1 ct1; ISomeInterface2 itf2;
4
by: mookid8000 | last post by:
Good day group! I have created a nice filtering plugin system, where all filters derive from a Filter class, and they pass a PictureData object between them. I have a problem though. I am able...
2
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.