Поделиться через


How to: Target a Specific .NET Framework Version or Profile

This document describes how to create a project that targets a specific .NET Framework version or profile, and how to change the target .NET Framework version for an existing project. For more information about how to change the .NET Framework version for C++ projects, see How to: Modify the Target Framework and Platform Toolset.

Note

In Express Editions of Visual Studio, a .NET Framework version or profile cannot be specified when a project is created. However, you can later retarget the project to any installed .NET Framework version.

Creating a Project

The following steps show how to create a project that targets a specific .NET Framework version.

To create a project that has a specific .NET Framework target

  1. In Visual Studio, on the File menu, click New and then click Project.

  2. In the New Project dialog box, select a project type, for example, Visual C# Windows.

  3. In the list at the top of the New Project dialog box, select the .NET Framework version you want your project to target, for example, .NET Framework 4.

    Note

    Visual Studio 2010 includes only the .NET Framework 4. To target earlier versions of the .NET Framework, you must have the .NET Framework 3.5 SP1 installed. To download and install the .NET Framework 3.5 SP1, see Microsoft .NET Framework 3.5 Service Pack 1 on the Microsoft Download Center website.

  4. Click OK and then continue to create your project.

    Note

    The set of available project templates depends on the .NET Framework version you select.

Changing the Target .NET Framework Version or Profile for an Existing Project

The following steps show how to change the .NET Framework target for an existing project.

To change the target .NET Framework version or profile

  1. In Visual Studio, open the project you want to change.

  2. Right-click the project in Solution Explorer and then click Properties.

  3. In the Project Designer, locate the Target Framework list, as follows.

    • For Visual Basic projects, click the Compile tab and then click Advanced Compile Options. The Target Framework list is in the Advanced Compiler Settings dialog box.

    • For Visual C# projects, the Target Framework list is on the Application tab of the Project Designer. For more information, see Application Page, Project Designer (C#).

    • For Visual F# projects, the Target Framework list is on the Application tab of the Project Designer.

  4. In the Target Framework list, select the .NET Framework version or profile that you want.

    When you click OK, the project unloads and then reloads in the integrated development environment (IDE). The project now targets the .NET Framework version that you just selected.

    Note

    If you change the .NET Framework version, you may receive error messages if your code contains references to a different version. To resolve these errors, you must manually modify the references. For more information, see Troubleshooting .NET Framework Targeting Errors.

See Also

Tasks

How to: Modify the Target Framework and Platform Toolset

Reference

Application Page, Project Designer (C#)

Advanced Compiler Settings Dialog Box (Visual Basic)

Concepts

Visual Studio Multi-Targeting Overview

.NET Framework Client Profile

.NET Framework Multi-Targeting for ASP.NET Web Projects

Troubleshooting .NET Framework Targeting Errors