Converting unmanaged C++ code to C#

A customer recently asked about 3rd party tools to cover unmanaged C++ code to C#...  I know, I know C++ has IJW support, so it may not be necessary… and of course.NET is not a re-write strategy, so you can leverage your existing code in .NET with Com Interop or PInvoke as well… But that said, we try to do what the customers ask for… so if you have pointers for a tool to covert unmanaged C++ code to C# I’d love to hear it.



Comments (11)

  1. Uwe Keim says:

    Probably he means a MFC to C# conversion tool…

  2. yeah Uwe. I was thinking, is that even remotely feasible. Forget about the differences in the actual languages, just the BCL/package mappings would be a nightmare.

  3. Sean Malloy says:

    An MFC to WinForms conversion tool would be ace.

  4. AprilR says:

    Brad – we love you for sharing the message!

    RE: MFC…You will be able to do some integration between MFC and Winforms in Beta 2 of Whidbey so you can add new Winform views to your existing MFC app. I don’t immediately find a paper on this on MSDN, I’ll check with our PM team.

    You can of course use the CLR from MFC as well – check out this case study:



  5. mihailik says:

    Reflector from Lutz Roeder can be such tool.

    1. Compile C++ code with /CLR option.

    2. Load assembly into Reflector.

    3. Use decompiler to get C# (or even VB!) code.

    This path of course can be repeated by Microsoft itself. You have that fine analyzis engine in FX Cop, why don’t let your FX Cop boys make a little money this month? 🙂

  6. Anonymous "Customer" who made the reques says:

    We’re actually looking for a tool to generate pInvoke code for unmanaged c++ .h.

    There are, we know, ambiguities in translation of c++ interfaces to .Net, but we are looking for a 90% accurate generation.

    I figured you guys in Redmond would have made something like this to generate code for all the Win32 API’s that you have wrapped. Guess not! 🙂

    Thanks in advance….

  7. We do have, but we don’t have a tool I know to autogen these

  8. Anonymous "Customer" says:

    Brad- Right, came across in my search. It’s a very nice idea – I installed the extensions too.

    Mihailik – I like that idea….. but we don’t have the C++ source.

    Thanks – look forward to hearing what else is out there!

  9. Ryan Rinaldi says:

    You might be looking for SWIG:

    Generates wrappers for for calling unmanaged code from .NET. I haven’t used it personally, but it seems like an interesting project.

  10. mihailik says:

    You can get it done using Borland Delphi.NET

    Delphi.NET package include ‘windows.pas’ and there is huge amount of Win32 defined. It written in Pascal language and it can be compiled to IL. And with Reflector IL==C#.

Skip to main content