Jump to content
Xtreme .Net Talk

Recommended Posts

Guest spike232
Posted

i have the following code that works for binary serilisation:

 

Private Sub binarysave(ByRef hold As Object, ByVal filename As String)
       Dim s As Stream = New FileStream(filename, FileMode.Create)
       Dim b As BinaryFormatter = New BinaryFormatter()

       b.Serialize(s, hold)
       s.Close()
   End Sub

 

however the folloing to do the same but using xml insted does not work, any ideas??

 

 
   Private Sub xmlsave(ByRef hold As settings, ByVal filename As String)
       Dim s As Stream = New FileStream(filename, FileMode.Create)
      Dim x As XmlSerializer = New XmlSerializer(GetType(settings))

       x.Serialize(s, hold)
       s.Close()
   End Sub

Guest spike232
Posted

i had that originaly it made no difference,

 

 

if i change the type pased to XmlSerializer to object it failes on the

x.Serialize(s, hold)

 

line with error:

An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll

 

Additional information: There was an error generating the XML document.

 

insted of the line

 

Dim x As XmlSerializer = New XmlSerializer(GetType(settings))

 

with error:

An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll

 

Additional information: There was an error reflecting 'MSN_No_Cut_Off.settings'.

 

and the class settings has been declared with <Serializable()>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...