473,657 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suppress debugger messagebox for unhandled exceptions in console app

Is there an app.config setting I can add or a System.Diagnost ic.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 5178
"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .netwrote in message
news:Ow******** ******@TK2MSFTN GP04.phx.gbl...
Is there an app.config setting I can add or a System.Diagnost ic.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******** **********@TK2M SFTNGP06.phx.gb l...
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.Configur ation 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******** ********@TK2MSF TNGP02.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.Configur ation 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
2311
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. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
2
2544
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 case of the code below the exception is handled by a little dialog that tries to tell me how to switch on jitDebugging. (which, if I am doing it correctly doesn't seem to help). All three options are checked under...
4
2141
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 isolate the error condition. The crash happens at seemingly random times and sometimes even when the application is just sitting there with no user interaction. We are interested in any ideas anyone has on how to trap this error. Are there any...
2
1314
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 to disable a dialog of my liking. Now if I run the application outside of the IDE I recieve the standard "Unhandled exception" dialog provided by .NET giving me the ability to continue or quit. I wasn't actually aware that exception handling...
3
2006
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 inconvenient for the user? Thanks Regards
2
2884
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) I receive the following error: "The type initializer for "System.Xml.Schema.Validator" threw an exception." I wrote a small console app that contains the problem -- I've just attached the default class which gets run. Output outside the...
1
2858
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 following error: "The type initializer for "System.Xml.Schema.Validator" threw an exception.". When running from the debugger (debug or release) no exception is thrown. I wrote a small console app that replicates the problem -- I've just attached...
3
2985
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 process finishes it causes an unhandled exception, even though both host and child process have all thread exceptions handled. Unfortunately this is making debugging a complete and utter nightmare as the application has already terminated by...
5
2192
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
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8302
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.