Enhanced Multi-targeting Support in Visual Studio 2010
Multi-targeting is a Visual Studio 2010 feature that lets you create applications targeting earlier versions of the .NET Framework.
According to Scott Guthrie:
VS 2010's multi-targeting support enables you to work on projects that target .NET 4.0, .NET 3.5, .NET 3.0 and .NET 2.0. It will allow you to start taking advantage of the new tooling features, without having to immediately upgrade the clients and servers running your application's to .NET 4.0. The improved multi-targeting support will ensure that this experience is even better and more accurate than before.
The Visual Studio 2010 IDE provides support for creating applications targeting at any one of the following versions of .NET Framework:
- .NET Framework 4.0
- .NET Framework 3.5
- .NET Framework 3.0
- .NET Framework 2.0
So, you can create and edit projects targeted at any one of the versions of .NET Framework stated above and you can now have all versions of .NET Framework reside side-by-side in your system.
Support for multi-targeting was also available in Visual Studio 2008. However, Visual Studio 2010 provides an enhanced support for multi-targeting. The ToolBox in Visual Studio 2010 IDE now displays only the controls that are part of the version of .NET Framework your application is targeted at. Also, Intellisense within the Visual Studio 2008 IDE used to display types and members of .NET Framework 3.5 even though your application was targeted at a different version of the .NET Framework. With Visual Studio 2010, you have Intellisense within the Visual Studio 2010 IDE display types and members that are only specific to the particular version of .NET Framework your application is targeted at. So, if your application is targeted at .NET Framework 2.0, you would notice Intellisense display only those types and members that are part of .NET Framework 2.0. You can find out more about multi-targeting support in Visual Studio 2010 here
For projects targeted at .NET Framework 4.0 or later, the application's web.config file contains the targetFramework attribute. Here's an example:
<configuration> <configSections>...</configSections> <appSettings/> <connectionStrings/> <system.web> <compilation debug="false" targetFramework="4.0"> </compilation> </system.web> </configuration>
Note that when you upgrade your project to .NET Framework 4.0 using Visual Studio 2010 IDE, the targetFramework attribute is automatically inserted in the application's web.config file. Also, this attribute is automatically removed from the application's web.config file when you switch to an earlier version of the .NET Framework. You can find out more on how to use multi-targeting for your ASP.NET projects here.