Search code examples
c#c++visual-studiocode-migration

Which C# project type would you use to redevelop a MFC C++ activex control?


Looking at the C# project templates in VS2008 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and .NET?


Solution

  • It sounds like you are trying to do several different things all at once:

    1. Migrate your code to building in a newer version of visual studio.
    2. Migrate your use of technology to a newer technology (ActiveX to .net)
    3. Migrate your language (c++ to c#).

    If you have a small codebase you are probably as well to start from scratch and port functionality into the new codebase as required.

    For a larger codebase you need to realize that this is an expensive task both in effort and defect rate.

    An order might be:

    1. Import your code into the newer version of visual studio. Get it compiling. Review the project settings for each project.
    2. Refactor your code to isolate the mfc and activex code as much as possible. Follow good refactoring practices especially if don't have many unit tests before you start.
    3. Consider replacing your ActiveX layer with .net.
    4. Consider which GUI toolkit is best for replacing MFC.
    5. Language - consider moving first to managed c++.
    6. Consider moving from managed c++ to c#.

    Most importantly be able to justify doing all of the above!