The cost of moving code from unmanaged to managed can be significant and I
do not mean to minimize that fact, but did want to address your statement
"...isn't possible to go completely to managed code. As speed is an
There is *not* a blank rule of thumb that says you are losing performance
for services by writing managed code. It really depends on the nature of
your application on whether C++ is faster. More to the point, is the
marshaling performance going to outweigh any performance benefits of keeping
code in C++. In fact, in certain cases managed code can simply out-perform
C++ code (memory allocation is a good example of this).
I do not suggest that you take the advice of any (or all) of us on this list
as the final arbiter because we cannot gleam the specifics of a complex
system by trading e-mails in this way. If, after this discussion, you are
still unsure...I would not hesitate to find a consultant (not a contractor,
but a real consultant) who can help you evaluate the decision(s).
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:DOTNET-CX@DISC...] On Behalf Of Alan Baljeu
Sent: Wednesday, March 28, 2007 3:35 PM
To: DOTNET-CX@DISC... Subject: Re: [DOTNET-CX] minimizing the cost of managed/unmanaged
Peter Ritchie writes:
> In terms of using your native API from managed, out of the
> box; I don't think there's anything specific for general
> performance between managed/unmanaged code. With VC2003,
> using IJW will be faster than doing the PInvoking yourself
> (or so I'm told).
I understand you to mean that using COM declarations in C# and C++ is the
faster way to
operate compared to declaring C API's in C# and calling them. If not,
please correct me.
> As you incrementanly move your native to managed you'll be
> able to get some performance metrics and test performance
I prefer writing in C#, but it isn't possible to go completely to managed
code. As speed is
an issue, perhaps I ought to migrate code in the other direction. I would
migrate some code
across the boundary in one direction or the other, if I had a good
understanding of the
costs of crossing that barrier, and knew that it was significant. If anyone
can direct me
in obtaining this understanding, please speak up.