Stack trace from an exception in a native C++ method

B

barker7

I am calling an unmanaged C++ method from C#. When an exception occurs
in the C++ code, it gets caught in our C# code.

CSharpMethod()
{
try
{
NativeCPPMethod();
}
catch (Exception e)
{
// The stack trace printed here starts at CSharpMethod
Console.Writeline(e);
}
}

The only problem is that there is no stack trace info about where the
exception occured in the C++ code. In other words the stack trace
starts from where I called the C++ method, and ignores all the methods
that might have been called inside the C++ code.

Is there a technique to see the stack trace for the methods in the
native C++ code?

I am using .Net 2.0. I am using dllImport(...) to link with the native
C++;

Thanks for any ideas.

Mitch
 
C

chanmm

If you can add your unmanaged C++ project in VS 2005 and add references from
your C# project then you can set a breakpoint on your C++. I am doing that
using managed C++ normally. Good luck.

chanmm
 
B

barker7

chanmm said:
If you can add your unmanaged C++ project in VS 2005 and add references from
your C# project then you can set a breakpoint on your C++. I am doing that
using managed C++ normally. Good luck.

That would be OK for debugging, but I ma looking for a solution that
can log exceptions during test or when used by those pesky users.
 
B

barker7

chanmm said:
If you can add your unmanaged C++ project in VS 2005 and add references from
your C# project then you can set a breakpoint on your C++. I am doing that
using managed C++ normally. Good luck.

That would be OK for debugging, but I ma looking for a solution that
can log exceptions during test or when used by those pesky users.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top