Click here to Skip to main content
15,887,135 members
Articles / Visual Studio / Visual Studio 2012

Visual Studio 2012 Set Default Target Framework to .NET4

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
28 Jan 2013CPOL2 min read 18.8K   3  
First time you create a new project in Visual Studio 2012, the target framework is set to .NET 4.5.

The first time you create a new project in Visual Studio 2012, the target framework is set to .NET 4.5. A lot of the fellow developers end up creating the project in .NET4.5 by accident.

image

Figure 1 – Default target framework in the new project window is .NET Framework 4.5

In this blog post, I’ll show you how to tweak the registry to default the target framework to .NET 4 just to avoid accidentally creating projects in .NET 4.5.

WARNING: This solution is neither recommended nor supported by Microsoft. Editing the registry can lead to serious problems if not done correctly. Always backup your registry before editing.

 

image

Figure 2 – Path to the registry key ‘FxVersion’ to change the default framework to 4.0

Steps to Change the Default Target Framework to .NET 4.0 in Visual Studio

  1. Open registry by typing Regedit in the command or run prompt
  2. Navigate to the path HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\NewProjectDialog and look for the key ‘FxVersion’.
  3. You’ll notice ‘FxVersion’ is currently set to 4.5
  4. Double click FxVersion and change the value to 4.0
  5. Close the Registry and try to create a new project in Visual Studio 2012
  6. Voila! The default target version should now be .NET Framework 4

image

Figure 3 – Default target framework set to .NET 4.0 after setting FxVersion to 4.0

Note – If you changed the value of the framework in the new window to let’s say .NET 3.5, then the value of the FxVersion key will change to 3.5 as well. So, I have created a .bat file that gets called when Visual Studio is loaded which basically resets the value of the key FxVersion to 4.0 to ensure that it remains as the default target framework for all new projects.

Happy coding!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Avanade
United Kingdom United Kingdom
Solution Developer - C# .NET, ALM

Tarun Arora is a Microsoft Certified professional developer for Enterprise Applications. He has over 5 years of experience developing 'Energy Trading & Risk Management' solutions using Microsoft Technologies. Tarun has great passion for technology and travel (not necessarily in the same order)!

Comments and Discussions

 
-- There are no messages in this forum --