Solved

Converting unmanaged VC++ code into managed code

Posted on 2004-08-06
1
360 Views
Last Modified: 2013-12-03
Can someone explain how a  project written in unmanaged VC++ ts converted into managed VC++.NET code? I am following the instructions given in the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcconAddingMCToExistingApplication.asp

Unlike what the link instructs, however, clicking on the target project’s Property Pages->General->C/C++ does not offer an option Compile As Managed. The only way to get to an option Compile As Managed, so that Assembly Support (/clr) can be chosen, is when one clicks on the individual .cpp files.

It turned out, however, that even finding that was not enough to compile correctly the individual .cpp file. One needs also to change the Debug Information Format and the Code Generation->Basic Runtime Checks.

After all the above was done on the individual .cpp files, the files compiled correctly. However, it turned out that if one closes the project and opens it again the changed parameters in the said .cpp files are not retained. The project continues to be unmanaged despite the changes that one has made during the first opening the project.

What should be done to really convert an unmanaged code into a managed one?
0
Comment
Question by:judico
1 Comment
 
LVL 19

Accepted Solution

by:
drichards earned 500 total points
ID: 11769161
A lot depends on the settings in use before you try to convert to /clr compilation.  In general, all you need to do is change the "Use Managed Extensions" property in "Configuration Properties->General" in the project properties dialog.  Setting this to "Yes" will automatically change some other settings (like set "Compile As Managed" to "Assembly Support (/clr)" for the cpp files).  You also need to say "#using <mscorlib.dll>" in your cpp file to actually use managed objects.

This link provides somewhat more complete information, though it is just the doc for the /clr compiler switch:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcrefEECOMCompilation.asp

It explains all the things you can't use once you throw the /clr switch.

Once you save the project files 'File->Save All", the setting should persist across project loads.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FizzBuzz challenge 9 76
canBalance challenge 34 70
wordmultiple challenge 12 121
Message not shown 5 33
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now