I have written a simple .NET Core console app (which writes some log files, hits a database and sends some emails). Triggering the task by double-clicking on the .exe within Windows works fine.
However when attempting to trigger the task through Task Scheduler it immediately fails with the code
0xC0000005. This failure happens when actually triggered on it's schedule or by right-clicking the task within the Task Scheduler app and clicking 'Run'. The first thing the app attempts to do is write something to a log file, which never happens.
The same server has a bunch of other .NET console apps (not .NET core) that are configured with exactly the same permissions and user accounts and they work fine.
In the event log there's a record that reads:
Faulting application name: StorePlay.ClientEmailer.exe, version:
220.127.116.119, time stamp: 0x58224b03 Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 Exception code: 0xc0000005
Fault offset: 0x00007ffaef1d8955 Faulting process id: 0xe0c Faulting
application start time: 0x01d301e534cdde90 Faulting application path:
C:\storePlay\Tasks\Client Emailer\StorePlay.ClientEmailer.exe Faulting
module path: unknown Report Id: 1bc8be44-744c-452e-a945-997d64d1d87b
Faulting package full name: Faulting package-relative application ID:
This is all on a machine running Windows Server 2016
I searched and tried all kinds of solutions and the one that worked for me was to set the Start In option. Normally someone could have the full path in the Program/Script text box after browsing, which is how most tasks I have seen run. It appears that .Net Core console app needs to run with the optional path so it can find the appsettings.json if you are using one.
It could be that the error is because of permissions. Usually the taskscheduler runs a task with the system account and when you run the exe in usual way on windows, then you run it with your credentials. You should be able to set your credentials on the task it self under task scheduler or create a user that has the permissions that it needs.
Edit: Did not see the age of the question until after posting an answer, but if it helps anyone else, then great :)
User contributions licensed under CC BY-SA 3.0