Re: Unhandled Exceptions outside of VS

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hello Bryce,

Exceptions are not propagated to the creator of a Windows Form message pump. You can catch the exception using the Application.ThreadException event:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsApplicationClassThreadExceptionTopic.asp?frame=true

Regards.


"Bryce Covert" <BryceCovert@xxxxxxxxxxxxxxxxxxxxxxxxx> escribió en el mensaje news:3D1B9182-C2D3-4FEF-9916-BB9EC8A7F934@xxxxxxxxxxxxxxxx
| Some of us on the .net framework were working on an issue that I've
| encountered. It seems that in this code, the catch will not catch the
| exception outside of Visual Studio. If run straight from the exe, it'll
| generate an unhandled exception.
|
| With some more testing, I've noticed this also happens with Application.Run.
|
| Any Ideas?
|
| Thanks!
|
| using System;
| using System.Windows.Forms;
|
| public class Test : Form
| {
| public Test()
| {
| Load += new EventHandler(LoadEventHandler);
| }
|
| private void LoadEventHandler(object sender, EventArgs args)
| {
| throw new Exception("Hello");
| }
|
| static void Main()
| {
| try
| {
| new Test().ShowDialog();
| }
| catch (Exception e)
| {
| Console.WriteLine ("Caught "+e);
| }
| }
| }

.



Relevant Pages

  • SqlCeConnection
    ... I have two module level SqlCeConnection objects, ... error but the Exception object does not contain a message to display. ... private void CloseConnection() ... SqlCeCommand sqlCommand = null; ...
    (microsoft.public.sqlserver.ce)
  • Re: Throwing Exceptions
    ... I just ran it and got the same result, it does not throw the exception! ... > private void InitializeComponent() ... > private void lblDest_DragDrop(object sender, ... >>> Create DragDrop event handler for label. ...
    (microsoft.public.dotnet.languages.csharp)
  • BeginExecuteReader doesnt work on one machine in my environment
    ... This exception is caught in the method, ... private delegate void loadReaderHandler(SqlDataReader sdr); ... private SqlConnection conn; ... private void aSynchTestHandler ...
    (microsoft.public.dotnet.framework.adonet)
  • Null exception error, Winforms
    ... The error is "An unhandled exception of ... private void btnSubCdAssign_Click(object sender, System.EventArgs e) ... stsFlag = true; ...
    (microsoft.public.dotnet.framework.windowsforms)
  • NullException on Exit app when performing updates on the dataset
    ... The error is "An unhandled exception of ... private void btnSubCdAssign_Click(object sender, System.EventArgs e) ... stsFlag = true; ...
    (microsoft.public.dotnet.framework.adonet)