Get more error information from unhandled error

Posted by Andrew Simpson on Stack Overflow See other posts from Stack Overflow or by Andrew Simpson
Published on 2014-05-27T14:58:05Z Indexed on 2014/05/27 15:25 UTC
Read the original article Hit count: 233

Filed under:
|
|

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)
    {

    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about dll