I ran a windows service i developed on a server that had a pre-required software component missing.
Sure enough the service crashed with a System.IO.FileNotFoundExcpetion: could not load file or assembly...
The thing is, when i deploy the exact same service, complied in debug, the catch block around my failing code is actually hit, and i get the chance to react (log, retry).
in example:
private void SampleMethodInService()
{
try
{
// this method uses objects that reside in an assembly that`s missing
MethodInMissingAssembly();
}
catch(Exception e)
{
// i'd like to log what happened, but don't get the chance.
}
}
if the code above is compiled in debug, the catch block handles the exception. if the code above is compiled in release, catch block is not hit and the process fails.
My question is: why is this ?
I have googled around for quite a while, but could not find any clues.