Share via


Cost of calling unmanaged code from managed C++

Question and answers about cost of calling unmanaged code from managed C++.


From:
Subject: RE: Cost of calling unmanaged code from managed C++

The biggest difference in performance is the cost of parameter marshalling. With C++ because you can work with native types directly from managed code, you can avoid or amortize the data marshalling cost, whereas with other .NET languages, you may end up incuring a managed to native type conversion for every P/Invoke call.


From:
Subject: RE: Cost of calling unmanaged code from managed C++

Calling unmanaged code from any .NET code is always done through a P/Invoke. In C++, there are situations when the linker can figure out where the P/Invoke is going and set it up for you, or you can explicitly use the attributes like C#, but the mechanism is the same. There should be no difference in performance.


From:
Subject: Cost of calling unmanaged code from managed C++

Hi,

I was wondering what the cost of calling unmanaged code from managed C++ is. Is it the same as doing a PInvoke from C#? In other words, if I call a Win32 native API from managed C++ is the overhead the same as calling it from C#? Why or why not?

Thanks!

Comments

  • Anonymous
    February 21, 2004
    Sam, My name is Junfeng Zhang, not Jennifer Zhang. Please get that right.
  • Anonymous
    February 21, 2004
    Gee, sorry. Fixed.
  • Anonymous
    June 09, 2009
    PingBack from http://besteyecreamsite.info/story.php?id=807