Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exception handling doesn't work in Release-version exe
Message
From
23/06/2005 09:18:21
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Exception handling doesn't work in Release-version exe
Miscellaneous
Thread ID:
01025814
Message ID:
01025814
Views:
123
A few days ago I stumbled over the problem that while developing using the Visual Studio NET IDE the MM error handling worked fine, but the release version of my program did not log exceptions, instead I got an "unhandled error" message.

After investigating the problem I found a similar message at dotnet247:
http://dotnet247.com/247reference/msgs/6/34274.aspx


So instead of using the standard setup:

class AppMainEntry : mmMainEntry
{
///
/// Static field that contains a reference to the application object
///

public static AppDesktop App;


///
/// Main application entry point
///

[STAThread]
public static void Main()
{
try
{

// Instantiate the Application Object
App = new AppDesktop();

// more code here [...]

// Instantiate the main application form
if (result == DialogResult.OK)
{
Application.Run(new MainForm());
}
}
catch (Exception e)
{
mmAppBase.Log.WriteException(e);

// Display the Exception form
mmExceptionForm ExceptForm = new mmExceptionForm(e.Message, e.StackTrace);
ExceptForm.ShowDialog();
}
finally
{
MessageBox.Show("finally");
}
}
}


I now use:
class AppMainEntry : mmMainEntry
{
///
/// Static field that contains a reference to the application object
///

public static AppDesktop App;


///
/// Main application entry point
///

[STAThread]
public static void Main()
{
Application.ThreadException +=new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

// Instantiate the Application Object
App = new AppDesktop();

// more code here [...]

// Instantiate the main application form
if (result == DialogResult.OK)
{
Application.Run(new MainForm());
}
}

private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs et)
{
Exception e = et.Exception;

mmAppBase.Log.WriteException(e);

// Display the Exception form
mmExceptionForm ExceptForm = new mmExceptionForm(e.Message, e.StackTrace);
ExceptForm.ShowDialog();

Application.Exit();

}
}

Maybe this is of help to others.

Greetings from Hamburg!

Soenke
Next
Reply
Map
View

Click here to load this message in the networking platform