简体   繁体   中英

Disable windows “debugging window” when calling program from the command line

I am starting a command line app from a C# application, this command line app is another C# application and from time to time it raises an exception and dies, this is not an issue in general and the code knows how to handle this case.

The issue is that whenever it raises this error that windows debugging window is shown. Is there any way I can disable that from the calling program? Like a ProcessStartInfo property I can use to prevent it from happening?

I can also change the command line program as well, but I´d rather not do it.

The thing you are seeing is the Just-In-Time Debugger , to make your program excluded from the list of detected programs that will launch the debugger you must put the name of your exe in the following registry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusionList

If you are running a 64 bit version of windows you should also add the exe name to

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusionList

Create a new REG_DWORD value, name it YourAppName.exe and set the value to 1 .

See this MSDN article for more detailed instructions.

The error is obviously caused by an unhandled exception.

Assuming it is a command line application, why don't you just put a try ... catch block wrapping the entire Main method and handle the exception in the appropriate way, like returning an error code to the console or something else you need/want to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM