Michael said:
I have legacy DLL code written in C++ that is essentially C code, an
implementation of a set of formulas used in our industry. There are
no DB or GUI interfaces, just exposed methods. I would like to
convert it to C# and if that is not possible to manage C++. I want
to use the DLL in a larger VB.Net program.
Is there a tool that will convert C++ to C#?
To be honest I would not recommend this. This is porting, and porting
creates ported code. Think about it. Your DLL has been written for the
unmanaged world by C++ experts with all of their understanding about
Win32 and the unmanaged world. The DLL has been code reviewed by Win32
experts. The DLL has been tested, tuned and debugged in the unmanaged
world, and presumably it has been used as a released product in the
unmanaged world. Don't you think that the best thing to do is to keep it
running in the unmanaged world?
If there are serious flaws, or if you plan to do substancially extend
the library, then there may be a good reason to write the code in C#.
But porting the code to C# or managed C++ IMO is not a great idea.
Instead use platform invoke so that the code will run in the unmanaged
world where it was designed to run and where it was tested and tuned.
Are there any articles/papers/examples on converting C++ to C#?
Not really, but in any case you should regard the process as being a
convertion from Win32 code to .NET code. There are large differences
between the two environments, and those differences are not necessarily
obvious in the differences between the two languages. At first sight C#
just appears to be a simplified version of C++ with some VB-isms added.
For example, C# has 'destructors' or at least it has a feature that uses
the C++ syntax for a destructor. However, it is NOT a C# destructor, and
behaves in a totally different way to a C++ destructor.
Are there any articles/papers/examples using managed C++ with VB.Net?
It does not matter. Managed C++ produces .NET assemblies. The code using
those assembies should not care what language was used to create the
assembly. And there *should* not be any artifacts in the assembly from
the language used to create it.
Richard