473,378 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Suppress debugger messagebox for unhandled exceptions in console app

Is there an app.config setting I can add or a System.Diagnostic.Process
property I can tweak to cause someone else's CLR 2.0 console app to not show
a base CLR dialog box offering to debug the app when an unhandled exception
is reached? On production systems, I still get a dialog box with Debug /
Close buttons. IMO, this completely violates the fundamentals of what a
console app should be, but that's beside the point. I just want to suppress
these dialog boxes.

I'm trying to host multiple standalone EXEs as processes in a controlled
Windows Service and am already logging the stderrout messages to the Windows
Event Log. Adding a try/catch block to the Main method in the console apps
to prevent the debugger dialogue box isn't always doable when it's someone
else's codebase.

Jon
May 15 '07 #1
3 5163
"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.netwrote in message
news:Ow**************@TK2MSFTNGP04.phx.gbl...
Is there an app.config setting I can add or a System.Diagnostic.Process
property I can tweak to cause someone else's CLR 2.0 console app to not
show a base CLR dialog box offering to debug the app when an unhandled
exception is reached?
So while I have not been able to find a positive answer on this anywhere on
the web, the conclusion I suppose is 'yes and no'. No, there is no .config
file entry to "fix" this, and no there is no flag to be sent to the CLR to
fix it.

However, yes, this is perfectly fixable. One hour in bed and I woke up
*ding* realizing how simple it is.

Since the qualification of my own question was that the console app is
indeed a CLR 2.0 console app, that means that it is a fully adaptable
assembly, which in turn means that the assembly can be loaded as though it
were a DLL. 99% of the time, these assemblies will be invoked with static
void Main(string[] args) method. There is no reason, then, why I cannot
simply create a new EXE stub that dynamically loads the assembly in question
and calls its Main() method, wrapping that in a try...catch.

Jon

May 16 '07 #2

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.netwrote in message
news:%2******************@TK2MSFTNGP06.phx.gbl...
Since the qualification of my own question was that the console app is
indeed a CLR 2.0 console app, that means that it is a fully adaptable
assembly, which in turn means that the assembly can be loaded as though it
were a DLL. 99% of the time, these assemblies will be invoked with static
void Main(string[] args) method. There is no reason, then, why I cannot
simply create a new EXE stub that dynamically loads the assembly in
question and calls its Main() method, wrapping that in a try...catch.
The problem here turns out that the application configuration settings get
loaded in the context of the calling process, not the target CLR EXE.

The System.Configuration namespace is pretty detailed, but the ability to
completely reset the loaded configuration for another CLR EXE that doesn't
know it's being "wrapped", that's something I'm finding difficulty tracking
down.

Jon
May 18 '07 #3

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
The problem here turns out that the application configuration settings get
loaded in the context of the calling process, not the target CLR EXE.

The System.Configuration namespace is pretty detailed, but the ability to
completely reset the loaded configuration for another CLR EXE that doesn't
know it's being "wrapped", that's something I'm finding difficulty
tracking down.
Trying brute force. I have my small EXE stub being copied to a temp
directory, along with the target EXE's nearby config files, and name the
stub EXE the same as the target EXE, and execute the stub with the
environment current directory to be the target EXE.

Jon
May 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: RalphTheExpert | last post by:
I'm getting different behavior if my code is running under the debugger or not. I have modified Winmain to look like this: // Copyright (C) 2002 Microsoft Corporation // All rights reserved....
2
by: Sam Miller | last post by:
Normally the debugger (visual studio .net environment) is good at pointing out the line of code that caused an exception.... except when that code is executed as part of a timer handler. In the...
4
by: canhamdlc | last post by:
We have a VB .NET application that even when we execute it in debug mode from within the Visual Studio IDE, it will crash and the debugger will not trap the error. This makes it nearly impossible to...
2
by: Nak | last post by:
Hi there, I'm just curious as to something. I have just added an exception handler at the entry point to my application, within the IDE any unhandled exceptions fallback to this and enable me...
3
by: John | last post by:
Hi I have a win app running under windows scheduler. Sometimes the just-in-time debugger comes up requiring the user to select a debugger. Is it possible to suppress this as it becomes...
2
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger (debug or release)...
1
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger I receive the...
3
by: NickP | last post by:
Hi there, Im experiencing an unhandled exception that seems to be impossible for me to catch. I am launching an assembly of mine from within another assembly using the Process object. Once the...
5
by: Jon Davis | last post by:
I'm hosting a .NET console application in a .NET Windows Service using System.Diagnostics.Process. How do I block the debugger dialogue from appearing? Thanks, Jon
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.