Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
All Visual C++ CLR projects link to the C run-time libraries by default. As a result, these projects are classified as mixed-mode applications, because they combine native code with code that targets the common language runtime (managed code). When they're compiled, they get compiled into intermediate language (IL), also known as Microsoft intermediate language (MSIL).
Important
Visual Studio 2015 deprecated and Visual Studio 2017 no longer supports the creation of /clr:pure or /clr:safe code for CLR applications. If you require pure or safe assemblies, we recommend you translate your application to C#.
If you're using an earlier version of the Microsoft C++ compiler toolset that supports /clr:pure or /clr:safe, you can use this procedure to convert your code to pure MSIL:
To convert your mixed-mode application into pure intermediate language
Remove links to the C runtime libraries (CRT):
In the .cpp file defining the entry point of your application, change the entry point to
Main(). UsingMain()indicates that your project doesn't link to the CRT.In Solution Explorer, right-click your project and select Properties on the shortcut menu to open the property pages for your application.
In the Advanced project property page for the Linker, select the Entry Point and then enter Main in this field.
For console applications, in the System project property page for the Linker, select the SubSystem field and change it to
Console (/SUBSYSTEM:CONSOLE).Note
You don't have to set this property for Windows Forms applications because the SubSystem field is set to
Windows (/SUBSYSTEM:WINDOWS)by default.In
stdafx.h, comment out all the#includestatements. For example, in console applications:// #include <iostream> // #include <tchar.h>-or-
For example, in Windows Forms applications:
// #include <stdlib.h> // #include <malloc.h> // #include <memory.h> // #include <tchar.h>For Windows Forms applications, in
Form1.cpp, comment out the#includestatement that referenceswindows.h. For example:// #include <windows.h>
Add the following code to
stdafx.h:#ifndef __FLTUSED__ #define __FLTUSED__ extern "C" __declspec(selectany) int _fltused=1; #endifRemove all unmanaged types:
Wherever appropriate, replace unmanaged types with references to structures from the
Systemnamespace. Common managed types are listed in the following table:Structure Description BooleanRepresents a Boolean value. ByteRepresents an 8-bit unsigned integer. CharRepresents a Unicode character. DateTimeRepresents an instant in time, typically expressed as a date and time of day. DecimalRepresents a decimal number. DoubleRepresents a double-precision floating-point number. GuidRepresents a globally unique identifier (GUID). Int16Represents a 16-bit signed integer. Int32Represents a 32-bit signed integer. Int64Represents a 64-bit signed integer. IntPtrA platform-specific type that is used to represent a pointer or a handle. SByteRepresents an 8-bit signed integer. SingleRepresents a single-precision floating-point number. TimeSpanRepresents a time interval. UInt16Represents a 16-bit unsigned integer. UInt32Represents a 32-bit unsigned integer. UInt64Represents a 64-bit unsigned integer. UIntPtrA platform-specific type that is used to represent a pointer or a handle. VoidIndicates a method that doesn't return a value; that is, the method has the voidreturn type.