0
votes

I develop a console application to generate a series of reports, if i double click the deployed app (.exe) it runs fine, but if i schedule the app with the Windows Task Scheduler i receive a message that said, {APP NAME} has Stop Working and the code never execute.

I can provide more info if needed on the comments

Windows Server 2008 standard SP2 .Net Framework 4.0 instaled

2
Please look into the Event Viewer if you find some more detailed information and post it here. Until then my guess goes into the user permission direction. - Marco
You might also try logging to a file anything that the app is trying to do. - crashmstr
In addition to permissions, you might have to set the application's working directory. It's an option in Task Scheduler. - Jim Mischel
The task scheduler is not logging anything on the Event Viewer, i am using the local administrator account and the same account is use as the caller for the task - Christopher Cabezudo Rodriguez

2 Answers

1
votes

I'm responding to an old post in case it helps someone else. I had the same issue. The event log said the program completed normally, but not even the first line of code would write to the log for me. It ended up being the "Start In" option in the Task Scheduler. It occurred to me that the program ran fine from the command line when I was in the current directory. There are manifest files and other dependencies in the same directory. So if you tell the scheduled job to start in the same directory as the EXE, you may get favorable results. It was the solution for me.

0
votes

I don't know what you have in your Main method, but you could try something like this:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += HandleUnhandledExceptionEvent;
        }

        private static void HandleUnhandledExceptionEvent(Object sender, System.UnhandledExceptionEventArgs e)
        {
            //write details to file or output to console, popup message, etc.
        }
    }
}

in my experience, those types of "stopped working" errors can sometimes be the result of an unhandled exception that gets thrown.

This is just a shot in the dark, but I hope it can help in your case.