Hi,
I have a problem using the XmlSerializer when I switch between two
databases (SQL Server and Oracle). Very puzzling!
If my app is set for SQL Server it works fine. Basically the app has
an object model which is serialized (using the XmlSerializer) and
stored in a database table.
If I then change the configuration to Oracle the following line of code
does not work:
XmlSerializer serializer = new XmlSerializer(typeof(DebtorCycles));
The exception is as follows:
System.TypeInitializationException: The type initializer for
"System.Xml.Serialization.Compiler" threw an exception. --->
System.Configuration.ConfigurationException: Unrecognized configuration
section DBType (C:\Documents and Settings\myuser\Desktop\New
Folder\ArrearsUI.exe.config line 4)
at
System.Configuration.ConfigurationRecord.ScanSecti onsRecursive(XmlTextReade*
r
reader, String configKey)
at System.Configuration.ConfigurationRecord.Load(Stri ng filename)
at System.Configuration.DefaultConfigurationSystem.En sureInit(String
configKey)
at
System.Configuration.DefaultConfigurationSystem.Sy stem.Configuration.IConfi*
gurationSystem.GetConfig(String
configKey)
at System.Configuration.ConfigurationSettings.GetConf ig(String
sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetCon figTable()
at System.Diagnostics.DiagnosticsConfiguration.Initia lize()
at System.Diagnostics.DiagnosticsConfiguration.get_Sw itchSettings()
at System.Diagnostics.Switch.Initialize()
at System.Diagnostics.Switch.get_SwitchSetting()
at System.Diagnostics.BooleanSwitch.get_Enabled()
at System.Xml.Serialization.Compiler..cctor()
--- End of inner exception stack trace ---
Now as you can see, there's a line in the exception text that states:
"Unrecognized configuration section DBType"
DBType is a setting in an app.config file but this file is only parsed
when the initial form loads and I've ensured the XmlTextReader I'm
using is closed.
Help appreciated.