Skip to content

Commit 7f497c4

Browse files
authored
Merge pull request MicrosoftDocs#3330 from corob-msft/docs/corob/issue-fixes-2020-12-08
Address cpp-docs 2634
2 parents 1ed9f71 + 2e7e416 commit 7f497c4

File tree

2 files changed

+145
-43
lines changed

2 files changed

+145
-43
lines changed
Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,72 @@
11
---
2-
title: ".NET Programming with C++/CLI (Visual C++)"
3-
ms.date: "09/18/2018"
2+
title: ".NET programming with C++/CLI"
3+
description: "Learn how to use C++/CLI to create .NET apps and components in Visual Studio."
4+
ms.date: 12/08/2020
45
helpviewer_keywords: ["programming [C++], .NET programming", ".NET Framework [C++]", ".NET applications [C++]", "Visual C++, .NET programming"]
5-
ms.assetid: 2c7f3b0f-a266-4f0e-b318-d6f1371e04a9
66
---
7-
# .NET Programming with C++/CLI (Visual C++)
7+
# .NET programming with C++/CLI
88

9-
**Visual Studio 2015**: By default, CLR projects created with Visual Studio 2015 target .NET Framework 4.5.2. To target .NET Framework 4.6 when you create a new project, in the **New Project** dialog, change the target framework in the dropdown at the top middle of the dialog. To change the target framework for an existing project, close the project, edit the project file (.vcxproj), and change the value of the Target Framework Version to 4.6. Next time you open the project, the settings will take effect.
9+
::: moniker range="msvc-140"
1010

11-
**Visual Studio 2017**: In Visual Studio 2017, the default framework is 4.6.1 and the Framework version selector is at the bottom of the **New Project Dialog**. C++/CLI itself is not installed by default. To install the component, open the Visual Studio Installer and choose the C++/CLI component under Visual C++.
11+
By default, CLR projects created with Visual Studio 2015 target .NET Framework 4.5.2. You can target .NET Framework 4.6 when you create a new project. In the **New Project** dialog, change the target framework in the dropdown at the top middle of the dialog. To change the target framework for an existing project, close the project, edit the project file (*`.vcxproj`*), and change the value of the Target Framework Version to 4.6. The changes take effect the next time you open the project.
1212

13-
## In This Section
13+
::: moniker-end
14+
::: moniker range="msvc-150"
1415

15-
[C++/CLI Tasks](../dotnet/cpp-cli-tasks.md)
16+
In Visual Studio 2017, the default target .NET Framework is 4.6.1. The Framework version selector is at the bottom of the **New Project** dialog.
1617

17-
[Native and .NET Interoperability](../dotnet/native-and-dotnet-interoperability.md)
18+
## Install C++/CLI support in Visual Studio 2017
1819

19-
[Pure and Verifiable Code (C++/CLI)](../dotnet/pure-and-verifiable-code-cpp-cli.md)
20+
C++/CLI itself isn't installed by default when you install a Visual Studio C++ workload. To install the component after Visual Studio is installed, open the Visual Studio Installer. Choose the **Modify** button next to your installed version of Visual Studio. Select the **Installed components** tab. Scroll down to the **Compilers, build tools, and runtimes** section, and select **C++/CLI support**. Choose **Modify** to update Visual Studio.
2021

21-
[Regular Expressions (C++/CLI)](../dotnet/regular-expressions-cpp-cli.md)
22+
::: moniker-end
23+
::: moniker range="msvc-160"
2224

23-
[File Handling and I/O (C++/CLI)](../dotnet/file-handling-and-i-o-cpp-cli.md)
25+
In Visual Studio 2019, the default target framework for .NET Core projects is 5.0. For .NET Frameworks projects, the default is 4.7.2. The .NET Framework version selector is on the **Configure your new project** page of the **Create a new project** dialog.
26+
## Install C++/CLI support in Visual Studio 2019
2427

25-
[Graphics Operations (C++/CLI)](../dotnet/graphics-operations-cpp-cli.md)
28+
C++/CLI itself isn't installed by default when you install a Visual Studio C++ workload. To install the component after Visual Studio is installed, open the Visual Studio Installer. Choose the **Modify** button next to your installed version of Visual Studio. Select the **Installed components** tab. Scroll down to the **Compilers, build tools, and runtimes** section, and select the latest **C++/CLI support for v142 build tools** component. Choose **Modify** to update Visual Studio.
2629

27-
[Windows Operations (C++/CLI)](../dotnet/windows-operations-cpp-cli.md)
30+
::: moniker-end
2831

29-
[Data Access Using ADO.NET (C++/CLI)](../dotnet/data-access-using-adonet-cpp-cli.md)
32+
## In this section
3033

31-
[Interoperability with Other .NET Languages (C++/CLI)](../dotnet/interoperability-with-other-dotnet-languages-cpp-cli.md)
34+
[C++/CLI tasks](../dotnet/cpp-cli-tasks.md)
35+
36+
[Native and .NET interoperability](../dotnet/native-and-dotnet-interoperability.md)
37+
38+
[Pure and verifiable code (C++/CLI)](../dotnet/pure-and-verifiable-code-cpp-cli.md)
39+
40+
[Regular expressions (C++/CLI)](../dotnet/regular-expressions-cpp-cli.md)
41+
42+
[File handling and I/O (C++/CLI)](../dotnet/file-handling-and-i-o-cpp-cli.md)
43+
44+
[Graphics operations (C++/CLI)](../dotnet/graphics-operations-cpp-cli.md)
45+
46+
[Windows operations (C++/CLI)](../dotnet/windows-operations-cpp-cli.md)
47+
48+
[Data access using ADO.NET (C++/CLI)](../dotnet/data-access-using-adonet-cpp-cli.md)
49+
50+
[Interoperability with other .NET languages (C++/CLI)](../dotnet/interoperability-with-other-dotnet-languages-cpp-cli.md)
3251

3352
[Serialization (C++/CLI)](../dotnet/serialization-cpp-cli.md)
3453

35-
[Managed Types (C++/CLI)](../dotnet/managed-types-cpp-cli.md)
54+
[Managed types (C++/CLI)](../dotnet/managed-types-cpp-cli.md)
3655

3756
[Reflection (C++/CLI)](../dotnet/reflection-cpp-cli.md)
3857

39-
[Strong Name Assemblies (Assembly Signing) (C++/CLI)](../dotnet/strong-name-assemblies-assembly-signing-cpp-cli.md)
58+
[Strong Name assemblies (assembly signing) (C++/CLI)](../dotnet/strong-name-assemblies-assembly-signing-cpp-cli.md)
4059

41-
[Debug Class (C++/CLI)](../dotnet/debug-class-cpp-cli.md)
60+
[Debug class (C++/CLI)](../dotnet/debug-class-cpp-cli.md)
4261

43-
[STL/CLR Library Reference](../dotnet/stl-clr-library-reference.md)
62+
[STL/CLR library reference](../dotnet/stl-clr-library-reference.md)
4463

45-
[C++ Support Library](../dotnet/cpp-support-library.md)
64+
[C++ support library](../dotnet/cpp-support-library.md)
4665

4766
[Exceptions in C++/CLI](../dotnet/exceptions-in-cpp-cli.md)
4867

4968
[Boxing (C++/CLI)](../dotnet/boxing-cpp-cli.md)
5069

5170
## See also
5271

53-
[Native and .NET Interoperability](../dotnet/native-and-dotnet-interoperability.md)
72+
[Native and .NET interoperability](../dotnet/native-and-dotnet-interoperability.md)
Lines changed: 104 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,140 @@
11
---
22
title: "How to: Create CLR Console Applications (C++/CLI)"
3-
ms.date: "11/04/2016"
3+
description: "Learn how to create CLR Console App projects to use C++/CLI in Visual Studio."
4+
ms.date: 12/08/2020
45
helpviewer_keywords: ["console applications, templates", "CLR console applications, project template"]
5-
ms.assetid: e89bce3c-706f-4ae0-8a90-cb1a0f674e70
66
---
77
# How to: Create CLR Console Applications (C++/CLI)
88

9-
You can use the Console Application template to create a console app project that already has essential project references and files.
9+
::: moniker range="msvc-140"
1010

11-
Typically, a console app is compiled into a stand-alone executable file but doesn't have a graphical user interface. A user runs the console app at a command prompt and uses the command prompt to issue instructions to the running app. Also at the command prompt, the app provides output information. The immediacy of a console app makes it a great way to learn programming techniques without concern for implementing a user interface.
11+
You can use the **CLR Console Application** template in the **New Project** dialog to create a console app project that already has essential project references and files.
1212

13-
When you use the Console Application template to create a project, it automatically adds these references and files:
13+
::: moniker-end
14+
::: moniker range="msvc-150"
15+
16+
You can use the **CLR Console App** template in the **New Project** dialog to create a console app project that already has essential project references and files.
17+
18+
C++/CLI support isn't installed by default when you install a Visual Studio C++ workload. If you don't see a CLR heading under Visual C++ in the **New Project** dialog, you may need to install C++/CLI support. For more information, see [.NET programming with C++/CLI](../dotnet/dotnet-programming-with-cpp-cli-visual-cpp.md).
19+
20+
::: moniker-end
21+
::: moniker range="msvc-160"
22+
23+
You can use the **CLR Console App (.NET Framework)** template in the **Create a new project** dialog to create a console app project that already has essential project references and files.
24+
25+
C++/CLI support isn't installed by default when you install a Visual Studio C++ workload. If you don't see CLR project templates in the **Create a new project** dialog, you may need to install C++/CLI support. For more information, see [.NET programming with C++/CLI](../dotnet/dotnet-programming-with-cpp-cli-visual-cpp.md).
26+
27+
::: moniker-end
28+
29+
Typically, a console app is compiled into a stand-alone executable file but doesn't have a graphical user interface. Users run the console app at a command prompt. They can use the command line to issue instructions to the running app. The app provides output information as text in the command window. The immediate feedback of a console app makes it a great way to learn programming. You don't need to worry about how to implement a graphical user interface.
30+
31+
::: moniker range="msvc-140"
32+
33+
When you use the CLR Console Application template to create a project, it automatically adds these references and files:
1434

1535
- References to these .NET Framework namespaces:
1636

17-
- <xref:System.AppDomainManager>—Contains fundamental classes and base classes that define commonly used values and reference data types, events and event handlers, interfaces, attributes, and processing exceptions.
37+
- <xref:System>, <xref:System.Data>, <xref:System.Xml>: These references contain the fundamental classes that define commonly used types, events, interfaces, attributes, and exceptions.
1838

19-
- mscorlibThe assembly DLL that supports .NET Framework development.
39+
- *`mscorlib.dll`*: The assembly DLL that supports .NET Framework development.
2040

2141
- Source files:
2242

23-
- Console (.cpp file)—The main source file and entry point into the app that you just created. It identifies the project .dll file and the project namespace. Provide your own code in this file.
43+
- *`ConsoleApplicationName.cpp`*: The main source file and entry point into the app. This file has the base name you specified for your project. It identifies the project DLL file and the project namespace. Provide your own code in this file.
2444

25-
- AssemblyInfo.cppContains attributes, files, resources, types, versioning information, signing information, and so on that you can use to modify the project's assembly metadata. For more information, see [Assembly Contents](/dotnet/framework/app-domains/assembly-contents).
45+
- *`AssemblyInfo.cpp`*: Contains attributes and settings that you can use to modify the project's assembly metadata. For more information, see [Assembly contents](/dotnet/framework/app-domains/assembly-contents).
2646

27-
- Stdafx.cppUsed to build a precompiled header file that's named Win32.pch and a precompiled types file that's named StdAfx.obj.
47+
- *`stdafx.cpp`*: Used to build a precompiled header file that's named *`ConsoleApplicationName.pch`* and a precompiled types file that's named *`stdafx.obj`*.
2848

2949
- Header files:
3050

31-
- Stdafx.h—Used to build a precompiled header file that's named Win32.pch and a precompiled types file that's named StdAfx.obj.
51+
- *`stdafx.h`*: Used to build a precompiled header file that's named *`ConsoleApplicationName.pch`* and a precompiled types file that's named *`stdafx.obj`*.
3252

33-
- resource.hA generated include file for app.rc.
53+
- *`resource.h`*: A generated include file for *`app.rc`*.
3454

3555
- Resource files:
3656

37-
- app.rcThe resource script file of a program.
57+
- *`app.rc`*: The resource script file of a program.
3858

39-
- app.icoThe icon file of a program.
59+
- *`app.ico`*: The icon file of a program.
4060

41-
- ReadMe.txtDescribes the files in the project.
61+
- *`ReadMe.txt`*: Describes the files in the project.
4262

43-
## To create a common language runtime (CLR) console app project
63+
::: moniker-end
64+
::: moniker range=">=msvc-150"
65+
66+
When you use the CLR Console App template to create a project, it automatically adds these references and files:
67+
68+
- References to these .NET Framework namespaces:
4469

45-
1. On the menu bar, choose **File**, **New**, **Project**.
70+
- <xref:System>, <xref:System.Data>, <xref:System.Xml>: These references contain the fundamental classes that define commonly used types, events, interfaces, attributes, and exceptions.
4671

47-
1. In the **New Project** dialog box, under **Installed Templates**, select the **Visual C++** node, select the **CLR** node, and then select the Console Application template.
72+
- *`mscorlib.dll`*: The assembly DLL that supports .NET Framework development.
73+
74+
- Source files:
75+
76+
- *`ConsoleApplicationName.cpp`*: The main source file and entry point into the app. This file has the base name you specified for your project. It identifies the project DLL file and the project namespace. Provide your own code in this file.
77+
78+
- *`AssemblyInfo.cpp`*: Contains attributes and settings that you can use to modify the project's assembly metadata. For more information, see [Assembly contents](/dotnet/framework/app-domains/assembly-contents).
79+
80+
- *`pch.cpp`*: Used to build a precompiled header file that's named *`ConsoleApplicationName.pch`* and a precompiled types file that's named *`pch.obj`*.
81+
82+
- Header files:
83+
84+
- *`pch.h`*: Used to build a precompiled header file that's named *`ConsoleApplicationName.pch`* and a precompiled types file that's named *`pch.obj`*.
85+
86+
- *`Resource.h`*: A generated include file for *`app.rc`*.
87+
88+
- Resource files:
89+
90+
- *`app.rc`*: The resource script file of a program.
91+
92+
- *`app.ico`*: The icon file of a program.
93+
94+
::: moniker-end
95+
96+
## To create a CLR console app project
97+
98+
::: moniker range="msvc-140"
99+
100+
1. On the menu bar, choose **File** > **New** > **Project**.
101+
102+
1. In the **New Project** dialog box, select the **Installed** > **Templates** > **Visual C++** > **CLR** node, and then select the **CLR Console Application** template.
103+
104+
1. In the **Name** box, enter a unique name for your application.
105+
106+
You can specify other project and solution settings, but they're not required.
107+
108+
1. Choose the **OK** button to generate the project and source files.
109+
110+
::: moniker-end
111+
::: moniker range="msvc-150"
112+
113+
1. On the menu bar, choose **File** > **New** > **Project**.
114+
115+
1. In the **New Project** dialog box, select the **Installed** > **Visual C++** > **CLR** node, and then select the **CLR Console App** template.
48116

49117
1. In the **Name** box, enter a unique name for your application.
50118

51-
You can specify other project and solution settings, but they are not required.
119+
You can specify other project and solution settings, but they're not required.
120+
121+
1. Choose the **OK** button to generate the project and source files.
122+
123+
::: moniker-end
124+
::: moniker range="msvc-160"
125+
126+
1. On the menu bar, choose **File** > **New** > **Project**.
127+
128+
1. In the **Create a new project** dialog box, enter "clr console" in the search box. Select the **CLR Console App (.NET Framework)** template, and then choose **Next**.
129+
130+
1. In the **Name** box, enter a unique name for your application.
131+
132+
You can specify other project and solution settings, but they're not required.
133+
134+
1. Choose the **Create** button to generate the project and source files.
52135

53-
1. Choose the **OK** button.
136+
::: moniker-end
54137

55138
## See also
56139

57-
[CLR Projects](../build/reference/files-created-for-clr-projects.md)
140+
[CLR projects](../build/reference/files-created-for-clr-projects.md)

0 commit comments

Comments
 (0)