Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exception handling doesn't work in Release-version exe
Message
De
23/06/2005 09:18:21
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Exception handling doesn't work in Release-version exe
Divers
Thread ID:
01025814
Message ID:
01025814
Vues:
127
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform