dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.2k stars 191 forks source link

The current version of the native library (1.4) does not support the original or minimum version of the ".NET Framework NGEN v4.0.30319" task (1.5/1.5) or task (1.6/1.6) #941

Closed LeanderClappaert closed 2 years ago

LeanderClappaert commented 2 years ago

Describe the bug I want to add a scheduled task from a Windows Server 2012 R2 machine to a Windows Server 2016 and Windows 11 machine. This is failing due to the error message below. I've seen some similar issues passing by, but see the 'additional context' part where I have a case where this used to work.

Windows Server 2016: The current version of the native library (1.4) does not support the original or minimum version of the ".NET Framework NGEN v4.0.30319" task (1.5/1.5). This is likely due to attempting to read the remote tasks of a newer version of Windows from a down-level client.

Windows 11: The current version of the native library (1.4) does not support the original or minimum version of the ".NET Framework NGEN v4.0.30319" task (1.6/1.6). This is likely due to attempting to read the remote tasks of a newer version of Windows from a down-level client.

Expected behavior I expect that the base machine, where you send a task from to another machine, can handle newer Task Library versions on that machine.

Environment (please complete the following information):

Additional context I used to work with 'Microsoft.Win32.TaskScheduler.dll' directly, version '2.4.2.0', and that works with the setup mentioned above, but there were some other issues that are resolved by using this library. So I'm hoping there is either a workaround or this bug can be resolved.

Update: some other changes that I did that maybe are related to this issue:

LeanderClappaert commented 2 years ago

Update: the issue occurs due to these changes: "I loop over all the tasks of the root folder and delete tasks by author or if they do not have a 'next execution' time + the last run time was at least 1 day ago."

LeanderClappaert commented 2 years ago

The issue was that I was using ts.RootFolder.AllTasks.Where(...).ToList() (ts == TaskService). I changed it to ts.FindAllTasks(...) and this works. Can be closed I guess?

dahall commented 2 years ago

Thanks for all the detail. I'll do some testing to determine why your first scenario using the AllTasks property behaves differently. That doesn't seem right to me and maybe a bug.

dahall commented 2 years ago

I found a bug that has been around for a long time when looking into your issue. Thank you. The next release of the library (2.10.2) will have identical behavior between the two methods you tried.

bogdan-patraucean commented 4 months ago

@dahall,, any idea when 2.10.2 might come? I encountered the same issue.

System.InvalidOperationException: The current version of the native library (1.6) does not support the version of the "UpdateConfiguration_S-1-5-80-3238277391-1891473654-1195688043-4149050645-2494734967" task (0.0)