By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Serialization of Object with SOAP XML String Embedded

P: n/a
I am not sure the appropriate newsgroup for this question,...I have also posted this on the XML.SOAP foru

Within a VB.NET application, I have two objects that are serializable. The second object contains a string variable containing the SOAP Serialized XML of the first object. If I serialize the second object into a string, I get very strange results with the string. I am certain there is a bug somewhere in the .NET framework causing this. Below is sample VB code that illustrated the problem using hashtables. Run the code, and note the message in the messagebox. Then uncomment the one line commented out and again look at the message box. You will see the text concatenated after the serialized string is missing

Thanks, and please let me know if I need to provide further clarification on the issue or if there is a more appropriate newsgroup to post this

Code

Dim formatter As New System.Runtime.Serialization.Formatters.Soap.SoapF ormatte
Dim ms As New System.IO.MemoryStrea
Dim x, thisOtherClassString, SeralizedObject As Strin
Dim thisOtherClass As New Hashtabl
Dim thisClass As New Hashtabl

thisOtherClass.Add("AA", "DD"
thisOtherClass.Add("AX", "ED"
thisOtherClass.Add("UU", "FF"

formatter.Serialize(ms, thisOtherClass
thisOtherClassString = System.Text.Encoding.ASCII.GetString(ms.GetBuffer( )

thisClass.Add("CX", "CXZ"
'thisClass.Add(thisOtherClassString, "test") '<---uncomment this line and again look at the messagebox result
thisClass.Add("CX2", "CXZ2"
thisClass.Add("CX3", "CXZ3"

ms = New System.IO.MemoryStrea
formatter.Serialize(ms, thisClass
SeralizedObject = System.Text.Encoding.ASCII.GetString(ms.GetBuffer( )
x = "this is before the string " & SeralizedObject.Trim & " this is after the string

MessageBox.Show(x) '<---note the exact text returne
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.