进程已启动但主要方法未执行 [英] Process has started but main method not executed

查看:79
本文介绍了进程已启动但主要方法未执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个非常简单的C#应用​​程序,我通过指定可执行文件的路径开始一个新进程。



它运作良好但有时会发生什么是新进程启动并停留一段时间并关闭但它没有达到Main方法(我保留了一些日志)。



我可以在任务管理器中看到新进程。



问题出现:



1.考虑新进程名称是Example.exe

2.我在Main方法和其他一些地方添加了一些日志

3.当我开始时Example.exe,它在任务管理器中显示一段时间并关闭。

4.但是日志没有被创建,意味着它没有执行/进入Main方法(它只发生一些次)

5.在大多数情况下效果都很好。



有人能给我一些提示吗,出了什么问题。



我尝试了什么:



我完全不知道如何跟踪开始新进程时发生的事情

解决方案

引用:

4 。但是Logs没有被创建,意味着它没有执行/进入Main方法(它只发生了几次)



错了。总是调用Main方法。问题是由于某种原因没有写日志。



如果没有看到代码,就不可能告诉你你做错了什么。


查看一些可用的调试工具,例如 Windows Sysinternals - Windows Sysinternals | Microsoft Docs [ ^ ] - 您可能得到一些线索。



另一个寻找线索的好地方 - Windows事件日志(Windows) [ ^ ]


Hi,

I have a very simple C# application, and am starting a new process by specifying path of the executable.

its works well but some times what happens is new process starts and stays for sometime and closes but it is not hitting the Main method(I have kept some logs ).

I can see new process in Task manager.

Problem Ex:

1. Consider new process Name is "Example.exe"
2. I have added some logs in the Main method and some other places
3. When I start "Example.exe", It shows in Task Manager for sometime and closes.
4. But Logs are not getting created, Means it has not executed/Entered the Main method(It happens only some times)
5. It works well in most of the cases.

Can anybody gives me some hint, whats going wrong.

What I have tried:

I do not know exactly how to track whats happening while starting a new process

解决方案

Quote:

4. But Logs are not getting created, Means it has not executed/Entered the Main method(It happens only some times)


Wrong. The Main method is ALWAYS called. The problem is the logs aren't being written for some reason.

Without seeing the code, it's impossible to tell you what you're doing wrong.


Have a look at some of the debug tools available e.g. Windows Sysinternals - Windows Sysinternals | Microsoft Docs[^] - you might get some clues.

Another good place to look for clues - Windows Event Log (Windows)[^]


这篇关于进程已启动但主要方法未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆