Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Converting unmanaged VC++ code into managed code

Posted on 2004-08-06
1
Medium Priority
?
382 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

824 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