By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,537 Members | 926 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,537 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Oct 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

<ba*****@yahoo.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
>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

Oct 27 '06 #2

P: n/a

chanmm wrote:
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.

Oct 28 '06 #3

P: n/a
chanmm wrote:
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.

Oct 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.