Issues with object serialization on Windows XP

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Dear,
I have a strange issue when trying to add a serialization feature to my software. I have extracted the code to a stupid test class and Im able to reproduce the issue while I think its done as described in the documentation.
The following codeImports System.IO
Imports System.Xml.Serialization

<Serializable()> _
Public Class SerializeableObject
Private var1 As Integer
Private var2 As Double
Private var3 As String

Public Sub New()
Me.var1 = 1
Me.var2 = 2.0
Me.var3 = "3"
End Sub
End Class

Public Class TestSerialization

Private testObj As SerializeableObject

Public Sub New()
Me.testObj = New SerializeableObject
End Sub

Reference documentation: http://support.microsoft.com/kb/316730/fr
Public Sub Save(ByVal filename As String, Optional ByVal errorBox As Boolean = True)
Save configuration to XML file
Try
Dim objStreamWriter As New StreamWriter(filename)
Dim serializer As New XmlSerializer(GetType(SerializeableObject))
serializer.Serialize(objStreamWriter, Me.testObj)
objStreamWriter.Close()
Catch ex As Exception
If errorBox Then
MessageBox.Show(ex.ToString, _
"Impossible to write configuration file to " + filename + "!", _
MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End If
End Try
End Sub
End Class

Raise the following exception:Exception: System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.serviceModel. (c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Configmachine.config line 134)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.DiagnosticsConfiguration.get_SwitchSettings()
at System.Diagnostics.Switch.InitializeConfigSettings()
at System.Diagnostics.Switch.InitializeWithStatus()
at System.Diagnostics.Switch.get_SwitchSetting()
at System.Diagnostics.BooleanSwitch.get_Enabled()
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)

Any idea of where the issue could be? I found a few post that reference a potential installation problem. Im doing the development on a clean and fresh Windows XP Pro installation with Visual Studio Express 2008.
Thanks in advance!
David

View the full article
 
Back
Top