A
Atara
My application starts with:
Module mmcMain
Public Sub Main()
Debug.WriteLine("Main begin")
Dim splashForm As New mcDlgs.cmcDlgSplash2
splashForm.Show()
....
Accidently I corrapted my config file (missing quote sign -> not valid
xml file) and I got unHandled Exception. Since my real users might also
do the same, I decided to handle this exception.
The information I had is:
An unhandled exception of type
'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: The '"' character, hexadecimal value 0x22,
cannot be included in a name. Line 82, position 34.
Call Stack:
system.dll!System.Configuration.ConfigurationSettings.SetConfigurationSy
stem(System.Configuration.IConfigurationSystem configSystem) + 0x74
bytes
system.dll!System.Configuration.ConfigurationSettings.GetConfig(string
sectionName) + 0x80 bytes
system.dll!System.Diagnostics.DiagnosticsConfiguration.GetConfigTable()
+ 0xe bytes
system.dll!System.Diagnostics.DiagnosticsConfiguration.Initialize()
+ 0x80 bytes
system.dll!System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
+ 0x7 bytes
system.dll!System.Diagnostics.TraceInternal.InitializeSettings() +
0x34 bytes
system.dll!System.Diagnostics.TraceInternal.get_Listeners() + 0x1b
bytes
system.dll!System.Diagnostics.TraceInternal.WriteLine(string
message) + 0x35 bytes
system.dll!System.Diagnostics.Debug.WriteLine(string message) + 0x6
bytes
so I added some code at the begginning of my Main():
Module mmcMain
Public Sub Main()
Try
Dim testStr As String =
System.Configuration.ConfigurationSettings.AppSettings("testStr")
Catch ex1 As System.Configuration.ConfigurationException
Dim strTitle As String = "MC2 Configuration Exception"
Dim strText As String = "Default values will be used." &
ControlChars.NewLine & ex1.ToString()
ShowMyDialog(strTitle, strText)
Catch ex As Exception
Dim strTitle As String = "other Exception"
Dim strText As String = ex.ToString()
ShowMyDialog(strTitle, strText)
End Try
' Debug.WriteLine("Main begin")
Dim splashForm As New mcDlgs.cmcDlgSplash2
splashForm.Show()
....
At the beginning I commented out the 'Debug.WriteLine' line to get all
my application functions that should catch the ConfigurationException,
but now, even if I do not comment out the "Debug" line, it does not
throw any exceptions.
To sum-up:
1) If I comment out the 'Try' block - the "Debug" throws exception. I
can understand that though there should be a simple way to handle it.
(How about .Net internal error handler "config file is corrupted" ???)
2) If I have the 'Try' block - the "Debug" does not throw exception,
(and I can see its output in the output window). Though the "Debug" line
is outside the Try block. Can you explain why does not it throw
exception?
3) Do you have any other ideas to handle the exceptions of corrupted
config file?
Thanks
Atara.
Module mmcMain
Public Sub Main()
Debug.WriteLine("Main begin")
Dim splashForm As New mcDlgs.cmcDlgSplash2
splashForm.Show()
....
Accidently I corrapted my config file (missing quote sign -> not valid
xml file) and I got unHandled Exception. Since my real users might also
do the same, I decided to handle this exception.
The information I had is:
An unhandled exception of type
'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: The '"' character, hexadecimal value 0x22,
cannot be included in a name. Line 82, position 34.
Call Stack:
system.dll!System.Configuration.ConfigurationSettings.SetConfigurationSy
stem(System.Configuration.IConfigurationSystem configSystem) + 0x74
bytes
system.dll!System.Configuration.ConfigurationSettings.GetConfig(string
sectionName) + 0x80 bytes
system.dll!System.Diagnostics.DiagnosticsConfiguration.GetConfigTable()
+ 0xe bytes
system.dll!System.Diagnostics.DiagnosticsConfiguration.Initialize()
+ 0x80 bytes
system.dll!System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
+ 0x7 bytes
system.dll!System.Diagnostics.TraceInternal.InitializeSettings() +
0x34 bytes
system.dll!System.Diagnostics.TraceInternal.get_Listeners() + 0x1b
bytes
system.dll!System.Diagnostics.TraceInternal.WriteLine(string
message) + 0x35 bytes
system.dll!System.Diagnostics.Debug.WriteLine(string message) + 0x6
bytes
mc2.exe!Synergix.mc.mmcMain.Main() Line 13 + 0xc bytes Basic
so I added some code at the begginning of my Main():
Module mmcMain
Public Sub Main()
Try
Dim testStr As String =
System.Configuration.ConfigurationSettings.AppSettings("testStr")
Catch ex1 As System.Configuration.ConfigurationException
Dim strTitle As String = "MC2 Configuration Exception"
Dim strText As String = "Default values will be used." &
ControlChars.NewLine & ex1.ToString()
ShowMyDialog(strTitle, strText)
Catch ex As Exception
Dim strTitle As String = "other Exception"
Dim strText As String = ex.ToString()
ShowMyDialog(strTitle, strText)
End Try
' Debug.WriteLine("Main begin")
Dim splashForm As New mcDlgs.cmcDlgSplash2
splashForm.Show()
....
At the beginning I commented out the 'Debug.WriteLine' line to get all
my application functions that should catch the ConfigurationException,
but now, even if I do not comment out the "Debug" line, it does not
throw any exceptions.
To sum-up:
1) If I comment out the 'Try' block - the "Debug" throws exception. I
can understand that though there should be a simple way to handle it.
(How about .Net internal error handler "config file is corrupted" ???)
2) If I have the 'Try' block - the "Debug" does not throw exception,
(and I can see its output in the output window). Though the "Debug" line
is outside the Try block. Can you explain why does not it throw
exception?
3) Do you have any other ideas to handle the exceptions of corrupted
config file?
Thanks
Atara.