Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 How to: Target a Specific .NET Fram...
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio
How to: Target a Specific .NET Framework

Updated: July 2008

The following procedures describe how to create a project that targets a specific .NET Framework version and how to change the target .NET Framework version for an existing project.

This procedure describes how to create a new project that targets a specific .NET Framework version.

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

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

    Doing this displays the New Project dialog box.

  2. Select a project type, such as Visual C# Windows Application.

  3. In the upper-right corner of the New Project dialog box, click the combo box and select the .NET Framework version you want your project to target, for example, .NET Framework 3.5.

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

NoteNote:

The project templates that are available depends on the .NET Framework version you choose.

This procedure describes how to change the .NET Framework version target of an existing project.

To change the .NET Framework version of a project

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

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

    Doing this displays the Project Designer.

  3. Go to the Target Framework drop-down list.

    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 (Visual Basic).

    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#).

  4. In the Target Framework list, click a .NET Framework version that differs from the current one for the project.

    The project now targets the new .NET Framework version. The project will unload and then reload in the integrated development environment (IDE). 

    NoteNote:

    If you change the .NET Framework target 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.

This procedure describes how to specifically target and require .NET Framework 3.5 SP1 for ClickOnce deployment only. 

After Visual Studio 2008 SP1, or .NET Framework 3.5 SP1, is installed, existing applications that only require .NET Framework 3.5 will still target .NET Framework 3.5. For applications that you want to specifically require .NET Framework 3.5 SP1, you must either incorporate one of the new ClickOnce features in Visual Studio 2008 SP1, which are listed in the following procedure, or add a reference to the new System.Data.Entity.dll assembly.

To specifically target.NET Framework 3.5 SP1

  1. In Visual Studio 2008, open the project that you want to target .NET Framework 3.5 SP1.

  2. Perform one of the following actions that enable an SP1 ClickOnce feature:

    • Specify an Error URL in the Publish Options dialog box.

    • Specify a Suite name in the Publish Options dialog box.

    • Create a desktop shortcut in the Publish Options dialog box.

    • Exclude a file from the hash in the Application Files dialog box.

    • Clear the Sign the ClickOnce manifests check box on the Signing page.

    -or-

    • Add a reference to the System.Data.Entity assembly.

    NoteNote:

    If you change the .NET Framework target, you may receive error messages if your code contains references to a different version. To resolve these errors, you must manually modify the references.

This procedure describes how to specifically target the .NET Framework Client Profile. The .NET Framework Client Profile provides a redistribution package that installs a subset of the .NET Framework on a target computer so that the full .NET Framework is not required to be present. For more information about the .NET Framework Client Profile, see .NET Framework Client Profile.

To specifically target.NET Framework Client Profile in Visual Basic

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

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

    Doing this displays the Project Designer.

  3. Click the Compile page.

  4. Click Advanced Compile Options.

  5. Select Client-only Framework subset.

To specifically target.NET Framework Client Profile in C#

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

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

    Doing this displays the Project Designer.

  3. Click the Application page.

  4. Select Client-only Framework subset.

Date

History

Reason

July 2008

Added a section about how to target .NET Framework 3.5 SP1 and the .NET Framework Client Profile.

SP1 feature change.

September 2008

Added clarification for ClickOnce deployment.

Customer feedback.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Any Targeting capability in Visual Studio 2005 ?      JAaronAndersondotcom ... Noelle Mallory - MSFT   |   Edit   |   Show History

This is a nice breakdown and hunky-dorie for 2008 but where is the setting for VS 2005 ? I need to match legacy code and Im deploying on an older server that was assigned to me? where is the target setting drop-down in VS2005 anyone know? thx

[Noelle Mallory - MSFT] Please post questions to the MSDN Forums at http://forums.microsoft.com/msdn. You will likely get a quicker response through the forum than through the Community Content.

Tags What's this?: Add a tag
Flag as ContentBug
Installation requirements for multi-targeted projects      Starbuck   |   Edit   |   Show History
I think it would be helpful to have an explicit mention of exactly which .NET Framework version is required to support a targeted platform. Example: Developer with VS2008 targets .NET 2.0. Does the developer need to separately install/update .NET 2.0 to run his code, or does the .NET 3.5 runtime process IL targeted to v2? Can an end-user receiving an assembly targeted to v2 run it with v3.5? I'm not asking the questions but suggesting this be clarified in this how-to for developers who need to provide information for deployment. Currently, my advice to anyone doing this is to load the target Framework on any system that will be used for development or deployment.
Tags What's this?: Add a tag
Flag as ContentBug
Applications can accidentally take a dependency on the service pack      David M. Kean - MSFT ... Thomas Lee   |   Edit   |   Show History

The following statement is actually misleading:

For applications that you want to specifically target .NET Framework 3.5 SP1, you must either incorporate one of the new ClickOnce features in Visual Studio 2008 SP1, which are listed in the following procedure, or add a reference to the new System.Data.Entity.dll assembly.

Applications can accidentally take a dependency on .NET 3.5 SP1 (and .NET 2.0 SP2 and .NET 3.0 SP2 which is installed by that service pack) simply by using one of the new methods or types that are added to the existing assemblies in the service pack. See: http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx for more information.

Targeted Framework option grayed out      kbenedict   |   Edit   |   Show History
Changing the Targeted Framework is not available for me. It says .NET 3.5, but I can't change it to anything else. Am I the only one on the Internet encountering this? This happens even if I start a new project.

Information on troubleshooting this issue would be nice.
Tags What's this?: Add a tag
Flag as ContentBug
Setup Projects      MattPil29   |   Edit   |   Show History
I think it would be useful to point out that setup projects detect the framework as a dependency and its not always the version you'd expect or want.

This needs to be checked/changed in two locations (vs2008):
  1. Right Click the setup project and select Properties. Click the 'Prerequisites' button and ensure the correct framework is checked.
  2. Under the setup project 'Detected Dependencies' Node double click the 'Microsoft .Net Framework' entry. Check the Version property.

So including the actual development project that's three places that need attention.

.NET 4.0 framework and VS 2008 ?      www.viewon.tv   |   Edit   |   Show History
Hi,

Is it possible to target the .NET 4.0 framework with VS 2008 ?

Also, can we run a particular application and force the .NET 4.0 , by command line ?

Thanks
Tags What's this?: .net (x) 2008 (x) 4 (x) studio (x) target (x) visual (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker