简体   繁体   English

为 Windows Server 2016 使用 Microsoft.Win32.TaskScheduler DLL

[英]Using the Microsoft.Win32.TaskScheduler DLL For Windows Server 2016

I have used the Microsoft.Win32.TaskScheduler DLL to list, display, and start Tasks in C# from the Task Scheduler on my Windows Server 2008 for years.多年来,我一直使用Microsoft.Win32.TaskScheduler DLL 从 Windows Server 2008 上的任务计划程序中列出、显示和启动 C# 中的任务。 I am upgrading the server to Windows Server 2016 and have encountered an issue when using this DLL.我正在将服务器升级到 Windows Server 2016,但在使用此 DLL 时遇到了问题。 When trying to get the Tasks on the server using this code:尝试使用此代码在服务器上获取任务时:

List<TaskObject> tasks = new List<TaskObject>();
using (TaskService ts = new TaskService(servername))
{
     tasks = ts.RootFolder.AllTasks.Where(x => x.Definition.Principal.UserId != null)
             .Select(x => new TaskObject(x, servername)).ToList();
}

I get the following error:我收到以下错误:

The current version of the native library (1.1) does not support the original or minimum version of the "EDP Policy Manager" task

I did some research and it looks like the Microsoft.Win32.TaskScheduler DLL was built for Windows Server 2008 and Windows Server 2003. Does anyone know if there is an updated DLL available or a fix?我做了一些研究,看起来Microsoft.Win32.TaskScheduler DLL 是为 Windows Server 2008 和 Windows Server 2003 构建的。有谁知道是否有可用的更新 DLL 或修复程序? Ultimately if there is not a solution regarding the Microsoft.Win32.TaskScheduler DLL, would anyone know of any similar DLL replacements that I should look into using?最终,如果没有关于Microsoft.Win32.TaskScheduler DLL 的解决方案,有人会知道我应该考虑使用的任何类似的 DLL 替换吗?

According to TaskScheduler official GitHub repo根据TaskScheduler官方 GitHub 存储库

The managed assembly closely resembles the new object model, but allows the 1.0 (internally version 1.1) COM objects to be manipulated.托管程序集与新对象模型非常相似,但允许操作 1.0(内部版本 1.1)COM 对象。 It will automatically choose the most recent version of the library found on the host system (up through 1.4).它将自动选择在主机系统上找到的最新版本的库(直到 1.4)。

So, the maximum supported version is 1.4.因此,支持的最大版本为 1.4。 It seems, that you should update the used version of this dll to the latest one from Nuget .看来,您应该将此 dll 的使用版本更新为Nuget的最新版本

Don't be confused by package or repository name, there is Microsoft.Win32.TaskScheduler.dll inside the package不要被包或存储库名称混淆,包内有Microsoft.Win32.TaskScheduler.dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM