Geeks With Blogs
Blog Moved to http://podwysocki.codebetter.com/ Blog Moved to http://podwysocki.codebetter.com/
I'm sure there are plenty of people still working in the .NET 1.1 world with Managed C++ who haven't quite moved to C++/CLI.  I'm finally taking some of my legacy applications that I have written and porting them over to C++/CLI.  Unfortunately, the conversion process wasn't very smooth, as I had a lot of unresolved externals once I tried to compile the application.
 
Microsoft has published a migration guide in order to bring your code "up to date" and gives a checklist that you must follow which is located here:  http://msdn2.microsoft.com/en-US/library/ms235289.aspx.  I found it quite straight forward although there is much work to be done to "fix" the apps. 
 
Luckily the applications I have been dealing with aren't the largest, so I decided to upgrade my keywords from MC++ to CLI.  This link was very helpful in doing so:  http://msdn2.microsoft.com/en-US/library/b23b94s7.aspx
 
Let's do some examples to show you how the upgrade process goes.
 
In this example I will take a sealed reference class and upgrade the keywords:
Before: public __gc __sealed class ArgumentValidation
After: public ref class ArgumentValidation sealed
 
In this next example, I will create a new XmlDocument
Before: XmlDocument* domDocument = new XmlDocument();
After: XmlDocument^ domDocument = gcnew XmlDocument();
 
This time, let's create an object array
Before: Object* params __gc[] = { myObject1 };
After: array<Object^>^ params = { myObject1 };
 
Here is another change that I found interesting with regards to NULL
Before: if(myObj == NULL) throw new ArgumentNullException(S"myObj");
After: if(myObj == nullptr) throw gcnew ArgumentNullException("myObj");
 
So, as you can see, there are quite a few changes required.  I could go on and on with the upgrades to the language, but that would take forever. 
Posted on Friday, May 5, 2006 10:04 AM Microsoft , .NET | Back to top


Comments on this post: Upgrading from Managed C++ to C++/CLI

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Matthew Podwysocki | Powered by: GeeksWithBlogs.net