Selecting .NET Target Framework in Visual Studio 2017 - c#

I'm trying to select target framework from the solution explorer, however all I can see is ".NET Standard 1.0" to 2.0 as available target. I've updated VS to the latest version (15.7.4) and have selected ".NET Desktop Development" workload in the installer. .NET 4-4.6 dev tools also already installed. So why can't I select them?

You've created a ".NET Standard" project and those are the only currently existing versions of the .NET Standard.
It sounds like what you want to create is a "standard" .NET project which is any of the options found under Windows Desktop in the New Project dialog (though none are by that name). This will give you the option of selecting which version of the .NET Framework you want to code against:

Related

How to change .NET Framework to .NET Standard/Core in Visual Studio?

I have a solution in C# in Visual Studios. It was first created in .NET Framework. I want to convert the project to .NET Standard/Core. If I go into project --> properties I see the attached screen, where Target Framework is .NET Framework. How am I able to change that to .NET Standard/Core?
As Roman Ryzhiy mentions in the comments, this is the way to go:
https://learn.microsoft.com/en-us/dotnet/core/porting/
This worked fine for me, I upgraded a .NET Framework 4.7.2 projekt. It was a small project, so I had few aftermath-problems. After the upgrade, the Target Framework in the Application tab will say ".NET 5.0".
Install upgrade-assistant:
dotnet tool install -g upgrade-assistant
Go to your solution folder
Run the assistant:
upgrade-assistant upgrade your-project-name.csproj
Follow the steps in the assistant, it's really straight-forward.
Also, here are the steps more detailed:
https://learn.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview#installation-steps

The C# Project is targeting ".NetFramework, Version=v4.5,Profile=Unity Full v3.5", which is not instaled on this machine

I tried to open a script in VS2015 from Unity 5.6.
For some reasons, this popup shows up and I click the first option and change the target to .Net Framework 4.5.2 and everything builds and works as expected.
However, every time I made changes in the Unity editor and switched back to Visual Studio, this dialog pops up again.
When I looked into the csproj files, I can see that, after I made changes in the Unity editor, I see this:
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Unity Full v3.5</TargetFrameworkProfile>
Then after I selected "Change the target to .NET Framework 4.5.2"
I see this:
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
It seems that the Unity editor is configured to change the .Net Framework to 4.5.
I tried to install .Net Framework 4.5 but it is already installed.
Is there any way I can either use .Net 4.5 in Visual Studio or change the target framework in Unity such that this dialog won't pop up again?
Before you do anything complicated, try this:
Open Edit>Project Setting>Player
Click Other Setting, go to Configuration, if the scripting runtime version is .NET 3.5, change it to .NET 4.x.
This not only fixed the warning, it also got back VS intellisense and the MathNet.Numerics can now be installed properly.
If this does not work, then try this link project-target-framework-not-installed.
In the Unity roadmap is stated that support for .net 4.6 will be added arround july 2017. The beta is out allready.
Scripting Runtime Upgrade (Preview)
Upgrade Mono and IL2CPP .NET runtimes to support the latest .NET functionality and APIs. This includes access to C# 6 and the .NET 4.6.x class library profile.
Currently Unity is only compatible with .net 3.5 but here is an workaround which may help.
If you have any of the .NET Framework v4.6 series allready installed you only need to install the Visual Studio 2015 Tools for Unity to be able to use the project without conversions.

Cannot target .Net 2.0 in Visual Studio 2015

I have a project that targets both .Net 2.0 and .Net 4.5. I built+published it successfully in Visual Studio 2013. The .Net configuration in the .csproj file still says
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
Yet, when I open the project in VS 2015, it targets .Net 4.5.
I have 2.0 available in the Target Framework dropdown:
when I click ".Net Framework 2.0" it gives me a popup saying
Changing the target framework requires that the current project be closed and then reopened.
Any unsaved changes within the project will be automatically saved.
Changing Target Framework my require manual modification of project files in order to build.
Are you sure you want to change the Target Framework for this project?
When I click yes, the target framework goes back to 4.5 and nothing else happens.
I've tried reopening the project and VS, with no luck.
I've tried running the .Net 3.5 installer (which apparently includes 2.0), but it says I need to use "Turn Windows Features on/off"
I've ensured the .Net 3.5 Windows Feature is enabled.
And now I'm out of ideas. Has anyone else encountered this?
Running Windows 7.
In case, the .NET Framework 2.0 is corrupted, use the .NET Framework setup verification tool: https://blogs.msdn.microsoft.com/astebner/2013/11/06/net-framework-setup-verification-tool-and-cleanup-tool-now-support-net-framework-4-5-1/ to verify and once it found any corrupted, you can use the .NET Framework Repair Tool: https://www.microsoft.com/en-us/download/details.aspx?id=30135 to repair it.
Or under ‘Turn Windows Features on or off’, uncheck .NET Framework 3.5 (includes .NET 2.0 and 3.0), then check it.
As Hans Passant mentions in the comments, I apparently(?) edited the .csproj to use different frameworks for different configurations. I swear this didn't cause any issues in VS 2013.
But in any case, I verified using ILSpy that the .dll being generated is .Net 2.0, even though the dropdown says 4.5. So I guess all's well that ends well?

How to generate installation requirements for my program?

I have a program in C# that was developed on a PC that has several of installed .NET frameworks, Service Packs, etc. How can I understand what are the minimal installation requirements in order to distribute the program to users? Should I start with a clean PC and test one-by-one .NET frameworks or is there a better approach?
Start by looking at the .NET version that your application is targeting.
If for example, you are targeting .NET 3.5 you will need to also include .NET 2.0
.NET 4.0 and 4.5 are self contained, so including earlier versions is not necessary for them.
You can check the version that you are targeting by going to the properties of your project (right click, properties in the solution explorer), clicking on the Build tab and looking for Target Framework
Microsoft recommends that you look for features that your application requires in the operating systems rather than look for which version of Windows you are targeting. So its better to list those out and tackle them one by one. I find this to be a bit overkill sometimes, but it does help once you get to logo certification.
check Target Framework in your Project Properties
Note :- Step for open project Solution
(Open Your Project in Visual Studio and then open solution explorer and Right click on Properties)
Some link to more Help you
1 : Retrieve Target Framework Version and Target Framework Profile from a .Net Assembly
2 : How to find the .NET framework version of a Visual Studio project?

How to recompile program for .Net Framework 3

I am using VS 2010 and i was trying to create program based on .Net Framework 4 and when i done it, program was working only on my computer, coz nobody of my friends don't have .Net framework 4 installed.
How to recompile program for .Net Framework 3 in Visual Studio 2010?
right-click on the project properties and change Target framework from .NET Framework 4 to .NET Framework 3
Go to the Project menu
Click on the Your Project Properties
On the Application Tab, select .NET Framework 3.5 from the Target Framework dropdown.
Simply change project settings.
Or use command-line csc to compile
You can switch the target framework in Visual Studio 2010 between .NET 2.0, 3.0, 3.5, and 4.0.
See How to: Target a Specific .NET Framework Version or Profile on MSDN.
As noted on that page, you might have to install 3.0 by hand since Visual Studio 2010 comes only with .NET 4.0. But once you install 3.0, you will be able to target it.
From the project in Visual Studio 2010, right click on the project and select Properties. Click on the Application tab, and from the Target Framework dropdown, select .NET Framework 3.0.
Project ->
Properties ->
Application (tab) ->
Target framework: .NET Framework 3.0
This MSDN page will help guide you with additional details.
And, not to be a schmuck, but you could have received a faster answer by Googling "compile .net framework 3.0 visual studio 2010" and noting that the first link is How To: Change the Target .NET Framework.

Categories