简体   繁体   English

我的 C# 应用程序将 0xE0434352 返回给 Windows 任务计划程序,但它没有崩溃

[英]My C# application is returning 0xE0434352 to Windows Task Scheduler but it is not crashing

I have written a few C# apps that I have running via windows task scheduler.我编写了一些通过 Windows 任务调度程序运行的 C# 应用程序。 They are running successfully (as I can see from the log files that they are writing ) but windows task scheduler shows them returning a last run result of 0xE0434352 .他们正在成功运行(正如我从他们正在编写的日志文件中看到的那样),但 Windows 任务调度程序显示他们返回了0xE0434352的最后一次运行结果。 Is there something I need to do in my C# application so that it returns a success code to the windows task scheduler?我需要在我的 C# 应用程序中做些什么,以便它向 Windows 任务调度程序返回一个成功代码?

Another option is to simply use the Application log accessible via the Windows Event Viewer.另一种选择是简单地使用可通过 Windows 事件查看器访问的应用程序日志。 The .Net error will be recorded to the Application log. .Net 错误将记录到应用程序日志中。

You can see these events here:您可以在此处查看这些事件:

Event Viewer (Local) > Windows Logs > Application事件查看器(本地)> Windows 日志 > 应用程序

When setup a job in new windows you have two fields " program/script " and " Start in(Optional) ".在新窗口中设置作业时,您有两个字段“程序/脚本”和“开始于(可选) ”。 Put program name in first and program location in second.将程序名称放在第一位,将程序位置放在第二位。 If you will not do that and your program start not in directory with exe, it will not find files that are located in it.如果您不这样做并且您的程序不在带有 exe 的目录中启动,则它将找不到位于其中的文件。

Hans Passant 是正确的,我为 AppDomain.CurrentDomain.UnhandledException 添加了一个处理程序,如下所述http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx我是能够找到正在发生的异常并纠正它。

我正在引用一个映射驱动器,我发现映射驱动器并不总是对运行计划任务的用户帐户可用,所以我使用了\\\\IPADDRESS而不是MAPDRIVELETTER:并且我已经启动并运行了。

In case it helps others, I got this error when the service the task was running at didn't have write permission to the executable location.如果它可以帮助其他人,当运行任务的服务没有对​​可执行位置的写权限时,我会收到此错误。 It was attempting to write a log file there.它试图在那里写一个日志文件。

I had this issue and it was due to the .Net framework version.我遇到了这个问题,这是由于 .Net 框架版本造成的。 I had upgraded the build to framework 4.0 but this seemed to affect some comms dlls the application was using.我已将构建升级到框架 4.0,但这似乎影响了应用程序正在使用的某些通信 dll。 I rolled back to framework 3.5 and it worked fine.我回滚到框架 3.5,它运行良好。

I got the same error but I have fixed it by changing the file reading path from "ConfigFile.xml" to AppDomain.CurrentDomain.BaseDirectory.ToString() + "ConfigFile.xml"我遇到了同样的错误,但我通过将文件读取路径从“ConfigFile.xml”更改为AppDomain.CurrentDomain.BaseDirectory.ToString() +“ConfigFile.xml”来修复它

In my case, this error due to file path error because task manager starts program from "System32" as initial path but the folder we thought.在我的情况下,这个错误是由于文件路径错误,因为任务管理器从“System32”作为初始路径启动程序,但我们认为是文件夹。

I was getting the same message message within dotNet Core 2.2 using MVC 5, however nothing was being logged to the Windows Event Viewer.我在使用 MVC 5 的 dotNet Core 2.2 中收到了相同的消息消息,但是没有任何内容记录到 Windows 事件查看器中。

I found that I had changed the Project sdk from Microsoft.NET.Sdk.Web to Microsoft.NET.Sdk.Razor (seen within the projects.csproj file).我发现我已将 Project sdk 从Microsoft.NET.Sdk.Web更改为Microsoft.NET.Sdk.Razor (在projects.csproj文件中可见)。 I changed this back and it worked fine :)我把它改回来了,效果很好:)

In my case it was because I had message boxes.就我而言,这是因为我有消息框。 Once I commented that code out, it started working.一旦我注释掉该代码,它就开始工作了。 I remembered that could be a problem when I looked at the event log as suggested in this thread.我记得当我按照这个线程中的建议查看事件日志时,这可能是一个问题。 Thank you everyone!谢谢大家!

I encountered this problem when working with COM objects.我在处理 COM 对象时遇到了这个问题。 Under certain circumstances (my fault), I destroyed an external .EXE process, in a parallel thread, a variable tried to access the com interface app.method and a COM-level crash occurred.在某些情况下(我的错),我破坏了一个外部 .EXE 进程,在一个并行线程中,一个变量试图访问 com 接口 app.method 并发生了 COM 级崩溃。 Task Scheduler noticed this and shut down the app.任务计划程序注意到这一点并关闭了该应用程序。 But if you run the app in the console and don't handle the exception, the app will continue to work ...但是如果你在控制台中运行应用程序并且不处理异常,应用程序将继续工作......

Please note that if you use unmanaged code or external objects (AD, Socket, COM ...), you need to monitor them!请注意,如果您使用非托管代码或外部对象(AD、Socket、COM...),则需要对其进行监控!

Also message box in PowerShell.还有 PowerShell 中的消息框。 I converted PowerShell script to exe.我将 PowerShell 脚本转换为 exe。 When running as admin it's worked but in task schedule I received this error also.以管理员身份运行时,它工作正常,但在任务计划中我也收到此错误。 There was an line in PowerShell script with write-output. PowerShell 脚本中有一行写输出。 After commented this line and compile new exe Task Schedule was completed successfully.注释此行并编译新的 exe 任务计划后成功完成。

在我的情况下,这是权限问题,任务调度程序有一个用户在数据库所在的服务器上没有权限。

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

相关问题 如何修复 .NET windows 应用程序在启动时崩溃并出现异常代码:0xE0434352? - How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352? Windows应用程序启动错误异常代码:0xe0434352 - Windows Application Startup Error Exception code: 0xe0434352 无法启动Azure辅助角色,异常代码0xe0434352和0xC0000035 - Unable to start Azure Worker Role, exception code 0xe0434352 & 0xC0000035 异常代码 0xe0434352 崩溃 w3wp.exe | 点网运行 - Exception code 0xe0434352 that crashes w3wp.exe | dotnet run 在Windows Task Scheduler中运行C#脚本? - run c# script in windows task scheduler? 除非用户登录,否则通过任务计划程序的 Windows C# 控制台应用程序将不会运行 - Windows C# Console Application Through Task Scheduler Won't Run Unless User Is Logged In c#console应用程序保持在任务计划程序窗口2016中运行的状态 - c# console application stays on status running in task scheduler windows 2016 为什么从Windows Task Scheduler运行时C#Application无法创建文件? - Why C# Application does not create file while running from windows task scheduler? 如何从服务器上的Windows Task Scheduler运行ac#控制台应用程序 - How to run a c# console application from windows task scheduler on server C#中的任务计划程序 - Task Scheduler in c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM