Get more error information from unhandled error
- by Andrew Simpson
I am using C# in a desktop application.
I am calling a DLL written in C that I do not have the source code for.
Whenever I call this DLL I get an untrapped error which I trap in an UnhandledException event/delegate.
The error is : object reference not set to an instance of an object
But the stack trace is empty.
When I Googled this the info back was that the error was being hanlded eleswhere and then rethrown. But this can only be in the DLL I do not have the source code for.
So, is there anyway I can get more info about this error?
This is my code...
in program.cs...
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Exception _ex = (Exception)e.ExceptionObject;
//the stact trace property is empty here..
}
finally
{
Application.Exit();
}
}
My DLL...
[DllImport("AutoSearchDevice.dll", EntryPoint = "Start", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
public static extern int Start(int ASD_HANDLE);
An I call it like so:
public static void AutoSearchStart()
{
try
{
Start(m_pASD);
}
catch (Exception ex)
{
}
}