.NET Core console app fails from task scheduler with 0xC0000005
Solution 1
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.
Solution 2
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 :)
Related videos on Youtube
Mick Byrne
Updated on September 18, 2022Comments
-
Mick Byrne over 1 year
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:
1.1.0.1179, 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
-
Naveed Abbas almost 6 yearsHi Setorica and welcome to ServerFault. Yes, around here we're in fact more concerned with general answers, good for everyone experiencing a similar problem.
-
Setorica over 5 yearsWhen you create a task in the task scheduler, then in the General tab, there should be settings for Security Options, where you can change which user account should run this task. Also you can set if it should be run as elevated/admin by checking the 'Run with highest privileges' checkbox.
-
Pier Giorgio Misley about 5 yearsI joined this community only to upvote that answer. 4h searching
-
Mohammed Dawood Ansari almost 5 yearssame here, just one thing to specify, in Program/scipt textbox, just keep the name of the program not the whole path, when I was trying, I just copied that path and pasted in the "Start" textbox and it wasn't working, may be helpful for some other dumb like me
-
Anthony Huang about 3 yearsYou saved my life. I was trying to use the task scheduler to run an asp.net core app at system startup but could not make it run. After setting the root folder of the app to the "Start in" text box as you mentioned above, it worked!