There are a number of solutions but i needed something that was relatively easy for a C# newbie (like yours truly), it had to be a runtime artifact where the code would reference (think dynamic loading) among other requirements. Voila, found a nice little library at Microsoft's Open Source website - yeah i know, for microsoft newbies like myself i had NO IDEA microsoft was INTO open source.
And so the story goes, there is this neat library called Application Management. Download it and check it out yourself. Might save you the time you needed. I know ;)
Let me give you a quick rundown of what its about. Basically, its a DLL and supports the major microsoft programming languages like C#, VB etc and so that's what made it nice because i created a sample application in C# and since it works, i know the VB.NET code i'm working on is likely to work. Cool.
So what you do?
- Create a C# project in Visual Studio 2010 (You can try VS2008, i didn't try it)
- Reference the DLL by adding it to your project (its ApplicationManagement.dll)
- You need to initialize it in your application. In this case, its the Program.cs
using ApplicationManagement;
namespace MyTestApp
{
static class Program
{
///
/// some other stuff
///
public static ExceptionHandler exceptionHandler;
static void Main()
{
exceptionHandler = new ExceptionHandler();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new Form1());
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
exceptionHandler.UnhandledException(sender, e);
}
So in your application code, it were to throw some form of exception then a user dump + stack trace would be created in your project's working directory. On my setup, its found at <project>\bin\Debug\Logs\AppErrors\
Well that's it. Have fun!
0 comments:
Post a Comment