I have this piece of code in a C# program:
ListOfCabins();
ListOfWoodTypes();
The first function looks as follows:
private void ListOfCabins()
{
Logger.Info($"Start function ListOfCabins()");
try
{
}
catch (Exception ex)
{
...
}
Logger.Info($"End of function ListOfCabins()");
}
The other function goes as follows:
private void ListOfWoodTypes()
{
Logger.Info($"Start function ListOfWoodTypes()");
...
Logger
is a typical NLog
object:
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
In the logs, I see:
End of function ListOfCabins()
I do not see:
Start function ListOfWoodTypes()
My application crashes, in the event log I see:
Application: ...
Framework Version: v4.0.30319
Description: The process wa terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at ...ListOfWoodTypes()
at ...
I have different questions here:
- A
System.IO.FileNotFoundException
, does this mean that my application is ok, tries to open some external file which is not present, or is it something like a Java process, missing a*.class
file? - Why is a
System.IO.FileNotFoundException
not catched by mytry ... catch (Exception ex)
clause? - What about the logs? I'm expecting to see at least the first line of the
ListOfWoodTypes()
function. Does this mean that there is some buffering inNLog
technology, causingNLog
logging to have some delay on a crash?
Edit1, debugging not possible
I'm developping this program on my own PC, I build it here, but I then copy the executable to my customer's PC, so debugging is not possible.
Reopen request
My question has nothing to do with ".NET Global exception handler in console application", it is specific about this one exception. Moreover this particular exception is not handled completely in the Windows event log, as can be seen in my own answer.