>oSoapFormatter.Serialize(oFileStream, oSoapFormatter) >>
>Imports System.IO >Imports System.Runtime.Serialization >Imports System.Runtime.Serialization.Formatters.Binary >Imports System.Runtime.Serialization.Formatters.Soap >Imports System.Reflection > >Public Class Form2 > > Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load > > Dim oHashTable As New Hashtable > > oHashTable.Add("One", 1) > oHashTable.Add("Two", 2) > oHashTable.Add("Three", 3) > > SaveSoapData("C:\Users.XML", oHashTable) > > End Sub > > Sub SaveSoapData(ByVal sFilename As String, ByVal oObjectToSave As Object) > > Try > > Dim oFileStream As FileStream = New FileStream(sFilename, FileMode.Create) > > Dim oSoapFormatter As New SoapFormatter(Nothing, New StreamingContext(StreamingContextStates.File)) > > oSoapFormatter.Serialize(oFileStream, oSoapFormatter) > > oFileStream.Close() > > Catch oError As Exception > > Dim sErrorString As String > sErrorString = "Message ---" & oError.Message > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "HelpLink ---" & oError.HelpLink > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "Source ---" & oError.Source > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "StackTrace ---" & oError.StackTrace > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "TargetSite ---" & oError.TargetSite.ToString > > MessageBox.Show(sErrorString, "Error") > > End > > End Try > > End Sub > > Function LoadSoapData(ByVal sFilename As String) As Object > > Try > > Dim oFileStream As FileStream = New FileStream(sFilename, FileMode.Open) > > Dim oSoapFormatter As New SoapFormatter(Nothing, New StreamingContext(StreamingContextStates.File)) > > LoadSoapData = oSoapFormatter.Deserialize(oFileStream) > > oFileStream.Close() > > Catch oError As Exception > > Dim sErrorString As String > sErrorString = "Message ---" & oError.Message > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "HelpLink ---" & oError.HelpLink > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "Source ---" & oError.Source > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "StackTrace ---" & oError.StackTrace > sErrorString = sErrorString & vbCrLf > sErrorString = sErrorString & "TargetSite ---" & oError.TargetSite.ToString > MessageBox.Show(sErrorString, "Error") > > End > > End Try > > End Function > >End Class >I think you want to change the line
oSoapFormatter.Serialize(oFileStream, oSoapFormatter)to
oSoapFormatter.Serialize(oFileStream, oObjectToSave)Also, note in the remarks section at http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.soap.soapformatter%28v=vs.110%29.aspx that SoapFormatter is obsolete and it is suggested that you use BinaryFormatter instead.