I have a c# console application. I also have windows task scheduler which I use to execute my exe file every morning.
I put a try catch block (shown below) to capture any errors and write the exception to a text file.
The actual process in the try block creates an excel instance and reads some data from a workbook. The code normally works. However when it fails the error never seems to be caught.
I have other applications which use the same code in the catch block to output the exception and know that this part works. Just seems the exception isn't be caught. I can see that the task scheduled started the file.
Update
I have checked the event viewer (thanks to a comment below) and can see that the task was successfully started
class Program
{
static void Main(string[] args)
{
try
{
// do some work
}
catch(Exception ex)
{
// write output to log file
}
}
}