Interop choices

K

keanep

Hi

I'd appreciate some advice on how to access legacy C++/Win32 libraries
from C#. We have a legacy Win32 application, mostly written in VC7.1,
and we want to re-write the GUI and maybe some business components in
C# (personally, I don't see the need,but the decision has been made).
We still want to keep a sizeable part of the libraries and utilities as
native Win32 libraries.
From the research I've done so far, I think these are the 4 choices we
can choose from. I'm thinking of proposing 2) for the most
performance-critical interop, 3) for native business components we
don't want to re-write in C# and 4) for the numerous native Win32
general utilities we have.

1) Build native libraries with /clr switch using VC7.1, then access
from C# as .NET assemblies

2) Build native libraries with /clr switch using VC8.0, then access
from C# as .NET assemblies

3) Package native libraries as COM servers and access from C# using COM
Interop service

4) Package native libraries as Win32 DLLs and access from C# using
P/Invoke service

Would be great if someone can offer some advice or references to assist
with the decision we have to make.

Best Regards
Peter
 
B

Ben Voigt

1) Build native libraries with /clr switch using VC7.1, then access
from C# as .NET assemblies

Unless you need to run on .NET 1.x, forget this option. C++/CLI is so much
better.
2) Build native libraries with /clr switch using VC8.0, then access
from C# as .NET assemblies

3) Package native libraries as COM servers and access from C# using COM
Interop service

4) Package native libraries as Win32 DLLs and access from C# using
P/Invoke service

#2 beats #4 hands-down, in effort required, performance, etc. You might
want both a native .dll and a C++/CLI assembly which imports that dll. The
C++/CLI wrapper code is more flexible than p/invoke, and leverages your
existing header files, so you can handle many changes in the native code
with a simple recompile.
 

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