Today I installed the .NET Framework 4.5 on my machine expecting to be able to use it from Visual Studio 2010, since it's just a minor update that should't pose problems for Visual Studio 2010. Unfortunately I am not, even manually removing certain 4.0 and adding the corresponding 4.5 assemblies resulted in the original 4.0 assemblies still being referenced in the project.
Is it possible to target version 4.5 from Visual Studio 2010 and if yes, how? I'd really like to use the ribbons...
FYI, if you want to create an Installer package in VS2010, unfortunately it only targets .NET 4. To work around this, you have to add NET 4.5 as a launch condition.
Add the following in to the Launch Conditions of the installer (Right click, View, Launch Conditions).
In "Search Target Machine", right click and select "Add Registry Search".
Add new "Launch Condition":
Where:
378389 = .NET Framework 4.5
378675 = .NET Framework 4.5.1 installed with Windows 8.1
378758 = .NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2
379893 = .NET Framework 4.5.2
Launch condition reference: http://msdn.microsoft.com/en-us/library/vstudio/xxyh2e6a(v=vs.100).aspx
I have been struggling with VS2010/DNFW 4.5 integration and have finally got this working. Starting in VS 2008, a cache of assemblies was introduced that is used by Visual Studio called the "Referenced Assemblies". This file cache for VS 2010 is located at \Reference Assemblies\Microsoft\Framework.NetFramework\v4.0. Visual Studio loads framework assemblies from this location instead of from the framework installation directory. When Microsoft says that VS 2010 does not support DNFW 4.5 what they mean is that this directory does not get updated when DNFW 4.5 is installed. Once you have replace the files in this location with the updated DNFW 4.5 files, you will find that VS 2010 will happily function with DNFW 4.5.
Each version of Visual Studio prior to Visual Studio 2010 is tied to a specific .NET framework. (VS2008 is .NET 3.5, VS2005 is .NET 2.0, VS2003 is .NET1.1) Visual Studio 2010 and beyond allow for targeting of prior framework versions but cannot be used for future releases. You must use Visual Studio 2012 in order to utilize .NET 4.5.
From another search. Worked for me!
"You can use Visual Studio 2010 and it does support it, provided your OS supports .NET 4.5.
Right click on your solution to add a reference (as you do). When the dialog box shows, select browse, then navigate to the following folder:
C:\Program Files(x86)\Reference Assemblies\Microsoft\Framework\.Net Framework\4.5
You will find it there."
There are pretty limited scenarios that I can think of where this would be useful, but let's assume you can't get funds to purchase VS2012 or something to that effect. If that's the case and you have Windows 7+ and VS 2010 you may be able to use the following hack I put together which seems to work (but I haven't fully deployed an application using this method yet).
Backup your project file!!!
Download and install the Windows 8 SDK which includes the .NET 4.5 SDK.
Open your project in VS2010.
Create a text file in your project named
Compile_4_5_CSharp.targets
with the following contents. (Or just download it here - Make sure to remove the ".txt" extension from the file name):Unload your project (right click -> unload).
Edit the project file (right click -> Edit *.csproj).
Make the following changes in the project file:
a. Replace the default
Microsoft.CSharp.targets
with the target file created in step 4b. Change the default platform to
.NET 4.5
c. Add
AnyCPU
platform to allow targeting other frameworks as specified in the project properties. This should be added just before the first<ItemGroup>
tag in the fileSave your changes and close the
*.csproj
file.Reload your project (right click -> Reload Project).
In the configuration manager (Build -> Configuration Manager) make sure the ".NET 4.5" platform is selected for your project.
Still in the configuration manager, create a new solution platform for ".NET 4.5" (you can base it off "Any CPU") and make sure ".NET 4.5" is selected for the solution.
Build your project and check for errors.
Assuming the build completed you can verify that you are indeed targeting 4.5 by adding a reference to a 4.5 specific class to your source code:
When you compile using the ".NET 4.5" platform the build should succeed. When you compile under the "Any CPU" platform you should get a compiler error: