Amazon.com Widgets

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.

 

Thanks

Published 28 February 05 07:40 by BradA
Filed under:

Comments

# Uwe Keim said on February 28, 2005 8:22 PM:
Probably he means a MFC to C# conversion tool...
# Paul D. Murphy said on February 28, 2005 9:17 PM:
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.
# Sean Malloy said on February 28, 2005 10:46 PM:
An MFC to WinForms conversion tool would be ace.
# AprilR said on February 28, 2005 11:20 PM:
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: http://www.microsoft.com/resources/casestudies/CaseStudy.asp?CaseStudyID=14934

Cheers.
aprilr
# mihailik said on March 1, 2005 4:47 AM:
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? :-)
# Anonymous "Customer" who made the reques said on March 1, 2005 6:47 AM:
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....
# Brad Abrams[MSFT] said on March 1, 2005 6:52 AM:
We do have http://PInvoke.net, but we don't have a tool I know to autogen these
# Anonymous "Customer" said on March 1, 2005 7:02 AM:
Brad- Right, came across PInvoke.net in my search. It's a very nice idea - I installed the vs.net 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!
# Ryan Rinaldi said on March 1, 2005 8:12 AM:
You might be looking for SWIG: http://www.swig.org/

Generates wrappers for for calling unmanaged code from .NET. I haven't used it personally, but it seems like an interesting project.
# mihailik said on March 1, 2005 8:31 AM:
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#.
New Comments to this post are disabled

Search

Go

This Blog

Syndication

Page view tracker