任务计划程序:WPF/C# 运行失败并出现错误(尽管在单独启动 .exe 时有效)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16326869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Task Scheduler: WPF/C# run failing with error (though works when launching .exe on its own)
提问by stack_rod
Fellow coders, I've built a WPF/ C# application (with .net 4), the app runs fine if debugging or even launching the ".exe" on its own, the app itself runs with Administrator privileges. While running with Administrator privileges I made it add itself as a Task in the "Task Scheduler". I've made sure the "Run with highest privileges" was checked while creating the task (and verified in the Task Schedulerthat everything was set like it was supposed to)
各位程序员,我已经构建了一个 WPF/C# 应用程序(使用 .net 4),如果调试或什至自行启动“.exe”,应用程序运行良好,应用程序本身以管理员权限运行。在以管理员权限运行时,我将其添加为“任务计划程序”中的任务。我确保在创建任务时检查了“以最高权限运行”(并在任务计划程序中验证了一切都按照预期设置)
When running the task, the task fails and I see this error: Task Scheduler failed to launch action "MYPATH\MyClient.Common.dll"in instance "{8df36ee7-0db9-4807-9b5d-d43a793f2169}" of task "\MyClient". Additional Data: Error Value: 2147942593.
运行任务时,任务失败,我看到此错误:任务计划程序无法在任务“\MyClient”的实例“{8df36ee7-0db9-4807-9b5d-d43a793f2169}”中启动操作“MYPATH\MyClient.Common.dll” . 附加数据:错误值:2147942593。
I don't understand where this is coming from specially that the MyClient.Common.dll has nothing special; just some logging stuff and a few helpers. Here are the dlls MyClient.Common.dll is referencing:
我不明白这是从哪里来的,MyClient.Common.dll 没有什么特别之处;只是一些日志记录和一些助手。以下是 MyClient.Common.dll 引用的 dll:
- Microsoft.CSharp
- System
- System.Core
- System.Data
- System.Data.DataSetExtensions
- System.Management
- System.Xml
- System.Xml.Linq
- 微软CSharp
- 系统
- 系统核心
- 系统数据
- System.Data.DataSetExtensions
- 系统管理
- 系统文件
- 系统文件.Linq
I've tried looking for the error value: "2147942593" but no luck. Thank you in advance!
我试过寻找错误值:“ 2147942593”但没有运气。先感谢您!
回答by Oren Trutner
Error code 2147942593 (hex 0x800700C1) is the HRESULT encapsulationof Windows error code C1, or ERROR_BAD_EXE_FORMAT.
错误代码2147942593(十六进制0x800700C1)是HRESULT封装Windows错误代码C1,或ERROR_BAD_EXE_FORMAT。
(search for 0xC1 in http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx)
(在http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx 中搜索 0xC1 )
In a task scheduler this often occurs in one of the following cases:
在任务调度程序中,这通常发生在以下情况之一:
The path points to a file that isn't an EXE program. If you literally entered the path to a DLL, this could be the cause.
The path includes spaces and isn't quoted. See Why "schtasks" does not run my job?
该路径指向一个不是 EXE 程序的文件。如果您从字面上输入了 DLL 的路径,这可能是原因。
路径包含空格且未引用。请参阅为什么“schtasks”不运行我的工作?

