tags:

views:

1073

answers:

4

We have a decent size MFC MDI desktop app. Is there a reasonable way to convert a MFC app to a .net app or is it better to just rewrite? If the answer is app specific, what criteria do you use to make the decision?

A: 

It would definately be a rewrite, but a lot of the concepts in MFC have .NET counterparts, so you would be able to map over a lot of your domain model. I'd use Windows Forms, since that would map easily to the same Win32 style UI that MFC offers.

If your MFC app separated the domain model and business rules nicely, you might even be able to use C++.NET to reuse some of that code, and either keep that unmanaged or turn that into managed classes, and optionally convert it to C# later on.

Dave Van den Eynde
A: 

When porting from MFC to WinForms you will have to rewrite the UI code, if you have good separation between UI and business logic you'll be better off porting the business logic either by using managed C++ or by translating it to C# (the syntax is just similar enough to make it possible).

I've done this for a small MFC application, I ported the business logic to c# by pasting the C++ code into a c# file and fixing the code until it started working, I rewrote the GUI from scratch.

This turned out to be a very smart move because we kept developing that into a large app and the end result is much better than anything we could have done in MFC in the same schedule.

We also have a huge MFC app with no clear separation between UI and business logic, we want to port it to .net but haven't figured out how to do it yet.

Nir
A: 

See my answer to this question which is basically the same as this one.

Aidan Ryan
A: 

I would skip WinForms and head right for WPF.

Depending on how your application is designed, you shouldn't have to rewrite everything. You can call C++ code from C# code using Managed C++ wrappers, allowing you to reuse existing C++ code. Microsoft also has extensive documentation on interoperation between WPF and Win32/MFC. You can do similar things with WinForms.

Microsoft has gone to great lengths to provide migration paths from MFC to WinForms/WPF because they know companies can't just throw away years of developed code.

Also, if you google "WPF and MFC" you'll find lots of examples of people using the two technologies in the same project.

17 of 26