Actually, configuration errors are thrown when the configuration is first
accessed, not when the appdomain is being loaded. If your service is
throwing an exception before OnStart is called you might want look at your
code and make sure you aren't accessing the ConfigurationManager somewhere
that would cause it to get thrown before the service has started.
The service is created in your Program.cs file (assuming you're using Visual
Studio), I'd start looking in there first. Also check your service class for
any static variables or class variables that are being set as the class is
being instantiated.
"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:BE**********************************@microsof t.com...
Hi Jason,
No, errors in the configuration files are thrown by .Net Framework before
the application is loaded. If this is a common issue, consider using a
separate configuration file and load it manually.
--
Happy Coding!
Morten Wennevik [C# MVP]
"Jason Richmeier" wrote:
>Is there a way to catch an application configuration error on startup?
I have written a windows service. If there is an error in the
configuration
file (such as invalid xml) the exception is thrown before the OnStart
method
is invoked. Is there a way to catch this exception?
Thank you,
Jason Richmeier