Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VC++ to C# migration guidelines/approaches/Issues

Tags:

c++

c#

migration

We are planning to move few of our VC++ Legacy products to C# with .NET platform.. I am in the process of collecting the relavent information before making the proposal to give optimistic and effective approach to clients. Am looking for the following details.

  1. Any general guidelines in migration of VC++ to C#.NET
  2. What are the issues that a team can face when we take up this activity
  3. Are there any existing approaches available ? I believe many might have tried but may not have detailed information, but consolidating this under this would help not only me but anyone who look for these information.
  4. Any good / valid resources available on internet?
  5. Any suggestions from Microsoft team if any Microsoft people in this group?
  6. Architecture, components design approaches, etc.

Please help me in getting these information, each penny would help me to gain good understanding..

Thanks in advance to those who will share their wisdom thorough this query.

like image 320
KSH Avatar asked Jan 11 '11 17:01

KSH


2 Answers

Often, my best advice is: Don't do it.

If you have functioning, clean C++ code, there is no reason to rewrite it. It is very easy to use C++/CLI to build wrappers around the legacy code to make it usable from C#/.NET.

This is often a better, quicker, and safer approach. You can then do your new development in .NET, and slowly migrate any existing code required if there is a real need to do so.

That being said, migrating code from C++ to C# is typically very much a complete, from scratch rewrite (unless you wrap as mentioned above). This is primarily because of the huge difference in libraries, not the difference in languages.

The .NET Framework provides a huge library of tools that can, and should, change the architecture of your code when written. If you just directly port the C++ to C#, you'll find that you'll be doing a lot of things in non-standard ways, and you'll end up with very difficult-to-maintain C# code.

My suggestion, based on my experience, is to wrap your code first. Then, if you decide you need to extend certain functionality, and it's unweildy because of the wrappers, you can rewrite that one specific portion of your code in C# using completely new techniques and libraries - and replace the C++ piece by piece.

like image 145
Reed Copsey Avatar answered Oct 04 '22 03:10

Reed Copsey


One gotcha, if you have a complicated class hierarchy, note that C# doesn't support multiple inheritance, so you may have to rethink the structure of your program.

Edit: Another thing to keep in mind is that the .net framework is very, very big. You may find utility classes in your c++ code that can be completely replaced by standard library classes in c#.

like image 29
Brennan Vincent Avatar answered Oct 04 '22 02:10

Brennan Vincent