473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Catching ConfigurationException when the config file is corrupted

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.ConfigurationSetti ngs.SetConfigurationSy
stem(System.Configuration.IConfigurationSystem configSystem) + 0x74
bytes

system.dll!System.Configuration.ConfigurationSetti ngs.GetConfig(string
sectionName) + 0x80 bytes

system.dll!System.Diagnostics.DiagnosticsConfigura tion.GetConfigTable()
+ 0xe bytes
system.dll!System.Diagnostics.DiagnosticsConfigura tion.Initialize()
+ 0x80 bytes

system.dll!System.Diagnostics.DiagnosticsConfigura tion.get_IndentSize()
+ 0x7 bytes
system.dll!System.Diagnostics.TraceInternal.Initia lizeSettings() +
0x34 bytes
system.dll!System.Diagnostics.TraceInternal.get_Li steners() + 0x1b
bytes
system.dll!System.Diagnostics.TraceInternal.WriteL ine(string
message) + 0x35 bytes
system.dll!System.Diagnostics.Debug.WriteLine(stri ng 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.AppSett ings("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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
1 3104
Anyone ?

Am I the only one that accidetly corrupted my config file?

How do you handle such situation in the real world were users that are
not familiar with xml have to change your well-formed .config files?

Thanks.
Atara


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Louis | last post by:
Hi All, When I build the application, the following error appear: An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll Additional...
1
by: BTHOMASinOHIO | last post by:
I am confussed on what the heck is going on ?! I have an HTML INPUT File Box on an Email Piece of an application. I know that File Size is set to 4MB in the WebConfig File and that is fine, but I...
9
by: ALI-R | last post by:
Hi,, I have two questions : 1) Is it mandatory that config file of a desktop application must be App.config 2) Is it possible to update config file in your code?? thanks for your help. ALI
2
by: sarvjeet Saini | last post by:
My application is working fine on our local server.We tried on two local servers for testing purpose. But when we host on our main server ,we got the following error: some it work Fine but not...
0
by: Cameron | last post by:
Hi All, I've just written a small program to use a locally hosted webservice which works fine. However I've also written a SOAPExtension for the client and I'm having trouble with the...
0
by: stephen | last post by:
Hi all, I am getting this error: An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.web.dll Additional information: Exception creating section...
7
by: jc | last post by:
i'm developing a project using vc++. the main exe is a win32 application. it needs two dlls. one is my own implementation of string operations. the other dll is to parse a2l files(it is similar to...
25
by: JJ | last post by:
I only want to catch 404 errors at the application level (the rest are will be handled by the customerrors section of the web.config). How do I check for the error code in the Application_Error...
14
by: Donn Ingle | last post by:
Yo, An app of mine relies on PIL. When PIL hits a certain problem font (for unknown reasons as of now) it tends to segfault and no amount of try/except will keep my wxPython app alive. My first...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.