Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Updated 14-Feb-18 6:26am
Comments
Leo Chapiro 14-Feb-18 8:37am    
Impossible to help without to see your source code.
johannesnestler 14-Feb-18 10:11am    
sounds not normal. Can't offer any help without seeing your "log-method" - Id guess - most likely there is something wrong with it (or the original call to the process). What could also be possible: If the process has an error in creating any static members (maybe you want to initialize some static members form configuration that is not present?), so maybe an exception is thrown BEFORE the Main method is executed.

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.
 
Share this answer
 
Comments
Sreekanth Puram 14-Feb-18 23:14pm    
"The problem is the logs aren't being written for some reason"
I have checked this case also, No event logs and code also not executed at all.
I checked that scenario.
Dave Kreskowiak 15-Feb-18 7:59am    
No, you haven't. As much as you say you have, you're missing stuff.

The Main method is ALWAYS called. It will NEVER be missed. The sole exception to this is if a virus scanner determines your executable isn't safe and quarentines it.

AGAIN, we can't see your code (because you haven't posted it!) so 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)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900