I have a console program written in C# that I am using to send faxes. When I step through the program in Visual Studio it works fine. When I double click on the program in Windows Explorer it works fine. When I setup a Windows scheduled task to run the program it fails with this in the event log.
EventType clr20r3, P1 consolefaxtest.exe, P2 1.0.0.0, P3 48bb146b, P4 consolefaxtest, P5 1.0.0.0, P6 48bb146b, P7 1, P8 80, P9 system.io.filenotfoundexception, P10 NIL.
I wrote a batch file to run the fax program and it fails with this message.
Unhandled Exception: System.IO.FileNotFoundException: Operation failed. at FAXCOMEXLib.FaxDocumentClass.ConnectedSubmit(FaxServer pFaxServer)
Can anyone explain this behavior to me?
I can’t explain it – but I have a few ideas.
Most of the times, when a program works fine testing it, and doesn’t when scheduling it – security is the case. In the context of which user is your program scheduled? Maybe that user isn’t granted enough access.
Is the resource your programm is trying to access a network drive, that the user running the scheduled task simply haven’t got?