473,320 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
3 3693
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Naresh Agarwal | last post by:
Hi Is there a way to copy the stack trace in a string, which is obtained via printStackTrace function of Exception object. Essentially I want to log the stack trace in case of any exception in...
7
by: Andy Fish | last post by:
Hi, in my c# code I have something like this: try { ... } catch (Exception ex) { ... throw ex; }
1
by: Mullin Yu | last post by:
I have some c# web services and c# application. I want to get and log the Exception Stack beside the exception message got from catch(Exception ex). Which class and method can do what I want? If...
0
by: Mike Schilling | last post by:
I have some code that calls methods reflectively (the method called and its parameters are determined by text received in a SOAP message, and I construct a map from strings to MethodInfos). The...
9
by: Jop | last post by:
Hi guys, I'm trying to debug a deployed application (no debug symbols) and what I got is a stack trace similar to this one. What does the '+' prefixed number after the method name signify? ...
2
by: Lasse Vågsæther Karlsen | last post by:
If I got the following code: try { // something that might throw an exception } catch (Exception ex) { // Log contents of ex here throw;
2
by: news.microsoft.com | last post by:
Hi all. If I wanted to write something so that, when an exception was thrown, and the stack unwound, the stack trace was captured with the values of the parameters (instead of just the parameter...
5
by: Mr. SweatyFinger | last post by:
WHY CAN'T THE CLOWN -HOLES WHO WROTE ASP.NET PROVIDE AN ERROR LINE NUMBER??? HONEST TO SH@THOLE PETE Server Error in '/New Folder (7)' Application....
3
by: Paul McGuire | last post by:
Is there any way to hide portions of an exception stack trace? When users get exceptions when using pyparsing, there are usually many layers of pyparsing-internal stack messages that are not at...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.