Visual Studio Multi-Targeting Overview
The multi-targeting feature of Visual Studio 2008 lets you specify the .NET Framework version that is required to use your application. The key benefit of multi-targeting is that you can use Visual Studio 2008 to create projects that target .NET Framework version 2.0, 3.0, or 3.5. This also lets you continue to develop projects that were created in Visual Studio 2005 without adding new .NET Framework dependencies. The multi-targeting feature helps guarantee that applications use only functionality that is available in the specified .NET Framework version. In addition, the multi-targeting feature lets you continue to deploy older applications without requiring you to add a new .NET Framework version in your deployment package.
Earlier versions of Visual Studio required you to install the latest .NET Framework version. For example, to use Visual Studio 2005, you also had to install .NET Framework 2.0. A new .NET Framework version may provide additional functionality, but it may also add new .NET Framework dependencies to your projects. These dependencies may prevent your applications from running on systems that they ran on before. That may be a problem if backward compatibility is required for your applications.
However, Visual Studio 2008 lets you target the specific .NET Framework version you want for your project by selecting it in the Framework Version box in the upper-right corner of the Open Project and New Project dialog boxes.
By default, when you upgrade Visual Studio 2005 projects to Visual Studio 2008, they continue to target .NET Framework 2.0. Optionally, you can switch the target from .NET Framework 2.0 to either .NET Framework 3.0 or .NET Framework 3.5, to take advantage of new features in those versions.
Visual Studio 2005 targeted the .NET Framework 2.0. Visual Studio 2008 lets you target additional .NET Framework libraries:
.NET Framework 3.0: Included in Windows Vista. Contains Windows Presentation Foundation, Windows Communication Foundation, and Windows Workflow Foundation.
.NET Framework 3.5: Included in Visual Studio 2008.
.NET Framework 3.5 SP1: Included in Visual Studio 2008 SP1.
.NET Framework Client Profile: Included in Visual Studio 2008 SP1. For more information about the .NET Framework Client Profile, see .NET Framework Client Profile.
Starting in Visual Studio 2008 SP1, you can specify .NET Framework 3.5 SP1 as an application target. However, .NET Framework 3.5 SP1 is not available on the Target Framework drop-down list. Therefore, for applications in which you want to specifically target .NET Framework 3.5 SP1, you must either add a reference to the new System.Data.Entity.dll assembly or perform one of the following actions that enable an SP1 ClickOnce feature in Visual Studio 2008 SP1:
Specify an Error URL.
Specify an Suite name.
Create a desktop shortcut.
Exclude a file from the hash in the Application Files dialog box.
Clear Sign the ClickOnce manifests on the Signing page.
When you take one of these actions, Visual Studio 2008 SP1 will automatically target .NET Framework 3.5 SP1. For more information, see "Targeting .NET Framework Version 3.5 SP1" in How to: Target a Specific .NET Framework.
After you install Visual Studio 2008 SP1, or .NET Framework 3.5 SP1, existing applications that only require .NET Framework 3.5 will still target .NET Framework 3.5.
The Framework Version combo box lets you specify a target deployment framework for your project. The list of available templates in this view is filtered according to the framework target specified. New Visual Studio 2008 projects automatically target the latest .NET Framework version (currently, .NET Framework 3.5) in order to provide all the newest features.
Visual Studio 2008 displays only controls and other project items that are relevant to the current target .NET Framework version, so that you do not unintentionally add a new dependency to a later .NET Framework version by adding a new control to your project.
In Visual Studio 2008, the Add Reference dialog box disables system assemblies that do not pertain to your target .NET Framework version. (System assemblies are .dll files that are part of, or have a dependency on, a .NET Framework version.) This helps you avoid adding references to assemblies that are not in your target version. If you modify your project file to include references that belong to a .NET Framework version that is newer than the one currently targeted by your project, your reference will not resolve. Also, you cannot add or use controls that depend on this reference. You can resolve this reference by switching the .NET Framework target of your project to one that includes this reference. You can do this on the project Property Page. For more information, see Managing Project Properties with the Project Designer.
If you add a reference to a user-created assembly that directly or indirectly references system assemblies that belong to a newer .NET Framework version than the version currently targeted by your project, Visual Studio 2008 will display a warning. If you ignore this warning, make sure that your deployment project includes all required .NET Framework files.
When you move a project to .NET Framework 3.5, a reference to System.Core and a project-level import for System.Linq (in Visual Basic only) are added automatically. If you want to use LINQ features, you must also turn Option Infer on (in Visual Basic only). The reference and import are removed automatically when you change the target .NET Framework version to 3.0 or 2.0. For more information, see How to: Create a LINQ Project.