Solved

Converting unmanaged VC++ code into managed code

Posted on 2004-08-06
1
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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…

717 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