为什么在 DLL 文件中启动的进程在使用控制台应用程序测试时可以工作,但在被另一个 DLL 文件调用时却不能工作?
上周我发布了这个问题当我将控制台应用程序作为 C# DLL 文件中的进程运行时,如何获取控制台应用程序输出? 因为我试图找出遇到问题的原因。但是,我一直无法找到出现错误的原因,所以我想我会询问直接与我遇到的问题有关的后续问题。
我正在研究 DLL 文件中的方法,并且必须在其中启动一个进程。用于执行此操作的代码是:
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.ErrorDialog = false;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.CreateNoWindow = true;
psi.FileName = @"C:\Program Files\OpenMS-1.6\XTandemAdapter.exe";
psi.Arguments = @"-ini C:\XTandemAdapter.ini";
Process getIDs = new Process();
getIDs.StartInfo = psi;
getIDs.Start();
StreamWriter inputWriter = getIDs.StandardInput;
StreamReader outputReader = getIDs.StandardOutput;
StreamReader errorReader = getIDs.StandardError;
getIDs.WaitForExit();
System.Diagnostics.EventLog.WriteEntry("FMANWiff", "ID output: " + outputReader.ReadToEnd());
System.Diagnostics.EventLog.WriteEntry("FMANWiff", "ID error: " + errorReader.ReadToEnd());
应用程序 XTandemAdapter.exe 通常作为控制台应用程序运行,文件名和参数旨在重现以下格式:
XtandemAdapter.exe -ini XTandemAdapter.ini
我有一个控制台测试应用程序,它调用此 DLL 文件中的方法。当我使用它时,我能够看到standoutput重定向的结果,并且我可以看到进程成功执行(调用的可执行文件还生成一个XML文件作为输出,我可以看到它已创建)。然而,正常的操作模式是应用程序调用 DLL 中的方法,而该方法最终又调用我的方法。当我以这种方式运行它时,我可以看到该进程是通过查看任务管理器创建的,但它很快退出,并且事件日志中没有输出,并且运行的可执行文件没有创建输出文件。
为什么它在一种情况下可以正常运行,但在另一种情况下却不能?通过控制台应用程序调用与通过 DLL 文件中的方法调用时执行的操作是否有所不同?
我注意到进程返回的退出代码是退出代码:-529697949,所以我猜进程中出了问题。我将查看 xtandemadapter 的代码并尝试找出它的来源。当我从控制台应用程序运行它时,它返回 0。
当我添加调试器中断语句时,我最终单步执行该方法并观察进程对象的值,无论是在使用控制台测试应用程序还是在现实世界中使用。我发现了差异,但我不知道如何理解它们。
工作控制台测试应用程序:
- getIDs {System.Diagnostics.Process (XTandemAdapter)} System.Diagnostics.Process
+ base {System.Diagnostics.Process (XTandemAdapter)} System.ComponentModel.Component {System.Diagnostics.Process}
BasePriority 8 int
EnableRaisingEvents false bool
ExitCode 9 int
+ ExitTime {10/4/2011 1:21:33 AM} System.DateTime
+ Handle 1036 System.IntPtr
HandleCount 53 int
HasExited true bool
Id 2732 int
MachineName "." string
+ MainModule 'getIDs.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModule {System.ComponentModel.Win32Exception}
+ MainWindowHandle 0 System.IntPtr
MainWindowTitle "" string
+ MaxWorkingSet 'getIDs.MaxWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ MinWorkingSet 'getIDs.MinWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ Modules 'getIDs.Modules' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModuleCollection {System.ComponentModel.Win32Exception}
NonpagedSystemMemorySize 3240 int
NonpagedSystemMemorySize64 3240 long
PagedMemorySize 3010560 int
PagedMemorySize64 3010560 long
PagedSystemMemorySize 120196 int
PagedSystemMemorySize64 120196 long
PeakPagedMemorySize 3010560 int
PeakPagedMemorySize64 3010560 long
PeakVirtualMemorySize 137424896 int
PeakVirtualMemorySize64 137424896 long
PeakWorkingSet 9064448 int
PeakWorkingSet64 9064448 long
+ PriorityBoostEnabled 'getIDs.PriorityBoostEnabled' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
+ PriorityClass 'getIDs.PriorityClass' threw an exception of type 'System.InvalidOperationException' System.Diagnostics.ProcessPriorityClass {System.InvalidOperationException}
PrivateMemorySize 3010560 int
PrivateMemorySize64 3010560 long
+ PrivilegedProcessorTime {00:00:00.0937500} System.TimeSpan
ProcessName "XTandemAdapter" string
+ ProcessorAffinity 'getIDs.ProcessorAffinity' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
Responding true bool
SessionId 0 int
+ StandardError {System.IO.StreamReader} System.IO.StreamReader
+ StandardInput {System.IO.StreamWriter} System.IO.StreamWriter
+ StandardOutput {System.IO.StreamReader} System.IO.StreamReader
+ StartInfo {System.Diagnostics.ProcessStartInfo} System.Diagnostics.ProcessStartInfo
+ StartTime {10/4/2011 1:21:32 AM} System.DateTime
SynchronizingObject null System.ComponentModel.ISynchronizeInvoke
+ Threads {System.Diagnostics.ProcessThreadCollection} System.Diagnostics.ProcessThreadCollection
+ TotalProcessorTime {00:00:00.8125000} System.TimeSpan
+ UserProcessorTime {00:00:00.7187500} System.TimeSpan
VirtualMemorySize 132001792 int
VirtualMemorySize64 132001792 long
WorkingSet 9064448 int
WorkingSet64 9064448 long
+ Static members
+ Non-Public members
当我按预期调用 dll 时,当它不起作用时:
- getIDs {System.Diagnostics.Process} System.Diagnostics.Process
+ base {System.Diagnostics.Process} System.ComponentModel.Component {System.Diagnostics.Process}
+ BasePriority 'getIDs.BasePriority' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
EnableRaisingEvents false bool
ExitCode -529697949 int
+ ExitTime {10/4/2011 1:03:09 AM} System.DateTime
+ Handle 4176 System.IntPtr
+ HandleCount 'getIDs.HandleCount' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
HasExited true bool
Id 596 int
MachineName "." string
- MainModule 'getIDs.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModule {System.ComponentModel.Win32Exception}
+ base {"Access is denied"} System.Runtime.InteropServices.ExternalException {System.ComponentModel.Win32Exception}
NativeErrorCode 5 int
+ Non-Public members
- MainWindowHandle 'getIDs.MainWindowHandle' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ base {"Process has exited, so the requested information is not available."} System.SystemException {System.InvalidOperationException}
+ MainWindowTitle 'getIDs.MainWindowTitle' threw an exception of type 'System.InvalidOperationException' string {System.InvalidOperationException}
+ MaxWorkingSet 'getIDs.MaxWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ MinWorkingSet 'getIDs.MinWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ Modules 'getIDs.Modules' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModuleCollection {System.ComponentModel.Win32Exception}
+ NonpagedSystemMemorySize 'getIDs.NonpagedSystemMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ NonpagedSystemMemorySize64 'getIDs.NonpagedSystemMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PagedMemorySize 'getIDs.PagedMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PagedMemorySize64 'getIDs.PagedMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PagedSystemMemorySize 'getIDs.PagedSystemMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PagedSystemMemorySize64 'getIDs.PagedSystemMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PeakPagedMemorySize 'getIDs.PeakPagedMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PeakPagedMemorySize64 'getIDs.PeakPagedMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PeakVirtualMemorySize 'getIDs.PeakVirtualMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PeakVirtualMemorySize64 'getIDs.PeakVirtualMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PeakWorkingSet 'getIDs.PeakWorkingSet' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PeakWorkingSet64 'getIDs.PeakWorkingSet64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PriorityBoostEnabled 'getIDs.PriorityBoostEnabled' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
+ PriorityClass 'getIDs.PriorityClass' threw an exception of type 'System.InvalidOperationException' System.Diagnostics.ProcessPriorityClass {System.InvalidOperationException}
+ PrivateMemorySize 'getIDs.PrivateMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PrivateMemorySize64 'getIDs.PrivateMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PrivilegedProcessorTime {00:00:00.0468750} System.TimeSpan
+ ProcessName 'getIDs.ProcessName' threw an exception of type 'System.InvalidOperationException' string {System.InvalidOperationException}
+ ProcessorAffinity 'getIDs.ProcessorAffinity' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ Responding 'getIDs.Responding' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
+ SessionId 'getIDs.SessionId' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ StandardError {System.IO.StreamReader} System.IO.StreamReader
+ StandardInput {System.IO.StreamWriter} System.IO.StreamWriter
+ StandardOutput {System.IO.StreamReader} System.IO.StreamReader
+ StartInfo {System.Diagnostics.ProcessStartInfo} System.Diagnostics.ProcessStartInfo
+ StartTime {10/4/2011 1:03:09 AM} System.DateTime
SynchronizingObject null System.ComponentModel.ISynchronizeInvoke
+ Threads 'getIDs.Threads' threw an exception of type 'System.InvalidOperationException' System.Diagnostics.ProcessThreadCollection {System.InvalidOperationException}
+ TotalProcessorTime {00:00:00.0781250} System.TimeSpan
+ UserProcessorTime {00:00:00.0312500} System.TimeSpan
+ VirtualMemorySize 'getIDs.VirtualMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ VirtualMemorySize64 'getIDs.VirtualMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ WorkingSet 'getIDs.WorkingSet' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ WorkingSet64 'getIDs.WorkingSet64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ Static members System.Diagnostics.Process System.Diagnostics.Process
+ Non-Public members {System.Diagnostics.Process} System.Diagnostics.Process
'getIDs.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception' Too many characters in character literal
我发现我在系统事件查看器中收到此错误。直到现在我才注意到这一点。
“应用程序弹出窗口:XTandemAdapter.exe - 应用程序错误:应用程序无法正确初始化 (0xe06d7363)。单击“确定”终止应用程序。”
这有助于任何人理解这个问题吗?我应该注意,可执行文件确实需要使用一些 DLL 文件,尽管根据 dependency walker 这些文件都已找到。
Last week I posted the question How can I obtain console application output when running it as a process in a C# DLL file? as I was trying to find out the cause of a problem I was having. However, I have not been able to find the reason I was getting an error, so I thought I would ask a follow up that is directly about the problem I am having.
I am working on method in a DLL file and I have to start a process in it. The code used to do this is:
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.ErrorDialog = false;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.CreateNoWindow = true;
psi.FileName = @"C:\Program Files\OpenMS-1.6\XTandemAdapter.exe";
psi.Arguments = @"-ini C:\XTandemAdapter.ini";
Process getIDs = new Process();
getIDs.StartInfo = psi;
getIDs.Start();
StreamWriter inputWriter = getIDs.StandardInput;
StreamReader outputReader = getIDs.StandardOutput;
StreamReader errorReader = getIDs.StandardError;
getIDs.WaitForExit();
System.Diagnostics.EventLog.WriteEntry("FMANWiff", "ID output: " + outputReader.ReadToEnd());
System.Diagnostics.EventLog.WriteEntry("FMANWiff", "ID error: " + errorReader.ReadToEnd());
The application XTandemAdapter.exe is normally run as a console application and the FileName and Arguments are meant to reproduce this format:
XtandemAdapter.exe -ini XTandemAdapter.ini
I have a console test application that calls my method in this DLL file. When I use this I am able to see the results of the redirect of standoutput and I can see that the process executed successfully (the executable that is called also produces an XML file as output and I can see that this was created). However, the normal mode of operation has a application call a method in a DLL which in turn ends up calling mine. When I run it this way I can see that the process was created by looking in the task manager, but it quickly exits and there is no output to the eventlog and no output file is created by the executable that was run.
Why would it run properly in one case, but not in another? Is something done differently when called via console application vs. being called by a method in a DLL file?
I noticed that the Exitcode returned by the process is Exitcode: -529697949 so I guess something is going wrong within the process. I will take a look at the code for xtandemadapter and try to figure out where this is coming from. When I run it from the console application it returns 0.
When I added the debugger break statement, I ended up stepping through the method and watched the value of the process objects, both when using the console test application and the real world use. I found differences, but I am not sure what to make of them.
Working console test application:
- getIDs {System.Diagnostics.Process (XTandemAdapter)} System.Diagnostics.Process
+ base {System.Diagnostics.Process (XTandemAdapter)} System.ComponentModel.Component {System.Diagnostics.Process}
BasePriority 8 int
EnableRaisingEvents false bool
ExitCode 9 int
+ ExitTime {10/4/2011 1:21:33 AM} System.DateTime
+ Handle 1036 System.IntPtr
HandleCount 53 int
HasExited true bool
Id 2732 int
MachineName "." string
+ MainModule 'getIDs.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModule {System.ComponentModel.Win32Exception}
+ MainWindowHandle 0 System.IntPtr
MainWindowTitle "" string
+ MaxWorkingSet 'getIDs.MaxWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ MinWorkingSet 'getIDs.MinWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ Modules 'getIDs.Modules' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModuleCollection {System.ComponentModel.Win32Exception}
NonpagedSystemMemorySize 3240 int
NonpagedSystemMemorySize64 3240 long
PagedMemorySize 3010560 int
PagedMemorySize64 3010560 long
PagedSystemMemorySize 120196 int
PagedSystemMemorySize64 120196 long
PeakPagedMemorySize 3010560 int
PeakPagedMemorySize64 3010560 long
PeakVirtualMemorySize 137424896 int
PeakVirtualMemorySize64 137424896 long
PeakWorkingSet 9064448 int
PeakWorkingSet64 9064448 long
+ PriorityBoostEnabled 'getIDs.PriorityBoostEnabled' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
+ PriorityClass 'getIDs.PriorityClass' threw an exception of type 'System.InvalidOperationException' System.Diagnostics.ProcessPriorityClass {System.InvalidOperationException}
PrivateMemorySize 3010560 int
PrivateMemorySize64 3010560 long
+ PrivilegedProcessorTime {00:00:00.0937500} System.TimeSpan
ProcessName "XTandemAdapter" string
+ ProcessorAffinity 'getIDs.ProcessorAffinity' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
Responding true bool
SessionId 0 int
+ StandardError {System.IO.StreamReader} System.IO.StreamReader
+ StandardInput {System.IO.StreamWriter} System.IO.StreamWriter
+ StandardOutput {System.IO.StreamReader} System.IO.StreamReader
+ StartInfo {System.Diagnostics.ProcessStartInfo} System.Diagnostics.ProcessStartInfo
+ StartTime {10/4/2011 1:21:32 AM} System.DateTime
SynchronizingObject null System.ComponentModel.ISynchronizeInvoke
+ Threads {System.Diagnostics.ProcessThreadCollection} System.Diagnostics.ProcessThreadCollection
+ TotalProcessorTime {00:00:00.8125000} System.TimeSpan
+ UserProcessorTime {00:00:00.7187500} System.TimeSpan
VirtualMemorySize 132001792 int
VirtualMemorySize64 132001792 long
WorkingSet 9064448 int
WorkingSet64 9064448 long
+ Static members
+ Non-Public members
When I call the dll as I expect to and when it does not work:
- getIDs {System.Diagnostics.Process} System.Diagnostics.Process
+ base {System.Diagnostics.Process} System.ComponentModel.Component {System.Diagnostics.Process}
+ BasePriority 'getIDs.BasePriority' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
EnableRaisingEvents false bool
ExitCode -529697949 int
+ ExitTime {10/4/2011 1:03:09 AM} System.DateTime
+ Handle 4176 System.IntPtr
+ HandleCount 'getIDs.HandleCount' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
HasExited true bool
Id 596 int
MachineName "." string
- MainModule 'getIDs.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModule {System.ComponentModel.Win32Exception}
+ base {"Access is denied"} System.Runtime.InteropServices.ExternalException {System.ComponentModel.Win32Exception}
NativeErrorCode 5 int
+ Non-Public members
- MainWindowHandle 'getIDs.MainWindowHandle' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ base {"Process has exited, so the requested information is not available."} System.SystemException {System.InvalidOperationException}
+ MainWindowTitle 'getIDs.MainWindowTitle' threw an exception of type 'System.InvalidOperationException' string {System.InvalidOperationException}
+ MaxWorkingSet 'getIDs.MaxWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ MinWorkingSet 'getIDs.MinWorkingSet' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ Modules 'getIDs.Modules' threw an exception of type 'System.ComponentModel.Win32Exception' System.Diagnostics.ProcessModuleCollection {System.ComponentModel.Win32Exception}
+ NonpagedSystemMemorySize 'getIDs.NonpagedSystemMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ NonpagedSystemMemorySize64 'getIDs.NonpagedSystemMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PagedMemorySize 'getIDs.PagedMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PagedMemorySize64 'getIDs.PagedMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PagedSystemMemorySize 'getIDs.PagedSystemMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PagedSystemMemorySize64 'getIDs.PagedSystemMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PeakPagedMemorySize 'getIDs.PeakPagedMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PeakPagedMemorySize64 'getIDs.PeakPagedMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PeakVirtualMemorySize 'getIDs.PeakVirtualMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PeakVirtualMemorySize64 'getIDs.PeakVirtualMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PeakWorkingSet 'getIDs.PeakWorkingSet' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PeakWorkingSet64 'getIDs.PeakWorkingSet64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PriorityBoostEnabled 'getIDs.PriorityBoostEnabled' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
+ PriorityClass 'getIDs.PriorityClass' threw an exception of type 'System.InvalidOperationException' System.Diagnostics.ProcessPriorityClass {System.InvalidOperationException}
+ PrivateMemorySize 'getIDs.PrivateMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ PrivateMemorySize64 'getIDs.PrivateMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ PrivilegedProcessorTime {00:00:00.0468750} System.TimeSpan
+ ProcessName 'getIDs.ProcessName' threw an exception of type 'System.InvalidOperationException' string {System.InvalidOperationException}
+ ProcessorAffinity 'getIDs.ProcessorAffinity' threw an exception of type 'System.InvalidOperationException' System.IntPtr {System.InvalidOperationException}
+ Responding 'getIDs.Responding' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
+ SessionId 'getIDs.SessionId' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ StandardError {System.IO.StreamReader} System.IO.StreamReader
+ StandardInput {System.IO.StreamWriter} System.IO.StreamWriter
+ StandardOutput {System.IO.StreamReader} System.IO.StreamReader
+ StartInfo {System.Diagnostics.ProcessStartInfo} System.Diagnostics.ProcessStartInfo
+ StartTime {10/4/2011 1:03:09 AM} System.DateTime
SynchronizingObject null System.ComponentModel.ISynchronizeInvoke
+ Threads 'getIDs.Threads' threw an exception of type 'System.InvalidOperationException' System.Diagnostics.ProcessThreadCollection {System.InvalidOperationException}
+ TotalProcessorTime {00:00:00.0781250} System.TimeSpan
+ UserProcessorTime {00:00:00.0312500} System.TimeSpan
+ VirtualMemorySize 'getIDs.VirtualMemorySize' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ VirtualMemorySize64 'getIDs.VirtualMemorySize64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ WorkingSet 'getIDs.WorkingSet' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
+ WorkingSet64 'getIDs.WorkingSet64' threw an exception of type 'System.InvalidOperationException' long {System.InvalidOperationException}
+ Static members System.Diagnostics.Process System.Diagnostics.Process
+ Non-Public members {System.Diagnostics.Process} System.Diagnostics.Process
'getIDs.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception' Too many characters in character literal
I found that I was getting this error in the system event viewer. I had not noticed it until now.
"Application popup: XTandemAdapter.exe - Application Error : The application failed to initialize properly (0xe06d7363). Click on OK to terminate the application."
Does this help anyone understand the problem? I should note, the executable does need to make use of a few DLL files, though according to dependency walker these are all found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不过,为什么没有记录事件则要有趣得多。我建议您将
System.Diagnostics.Debugger.Break();
放在应用程序的第一行中。这将允许您在调用调试器后附加调试器,然后您可以观察其行为。Why you aren't getting an event logged is far more interesting though. I suggest that you put a
System.Diagnostics.Debugger.Break();
in your application's first line. This will allow you to attach the debugger after it is invoked and then you can observe the behaviour.我会以“你好,世界!!”开始。控制台应用程序并与实际应用程序分开调试进程内容。
这可能会帮助您确定导致返回代码的原因(即您的调用代码或控制台应用程序)。
I would start with a "Hello, World!!" console application and debug the process stuff separately from your real application.
That might help you nail down what is causing the return code (i.e., your calling code, or the console application).
从控制台应用程序运行时它可以工作,但从其他程序运行的 DLL 文件运行时它会失败。
对我来说,这听起来像是安全上下文的问题。您的控制台应用程序可能以比其他程序更高的权限运行。
It works when run from a console application, but it fails when run from a DLL file running from a different program.
To me, it sounds like a problem with security context. Your console application may be running with higher privileges than the other program.