Solved

Converting unmanaged VC++ code into managed code

Posted on 2004-08-06
1
358 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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Universal fonts 2 138
Macro to save highlighted rows as a separate file 5 38
firstChar challenge 13 83
Change to event 1 72
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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…

743 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

17 Experts available now in Live!

Get 1:1 Help Now