How to fix TargetPlatformMinVersion problem in WPF app? - c#

I'm trying to use Windows UI library in my WPF app, and whenever I install Microsoft.UI.Xaml I get the following error.
Microsoft.UI.Xaml nuget package requires TargetPlatformMinVersion >= 10.0.15063.0 (current project is -1)
How to resolve this issue?
My windows SDK version is the latest version downloaded from here.
My OS version is 20H2 and the build number is 19042.685
I tried changing the targeted framework from .NET Core 3, 3.1, and .NET 5.
[If you think the title of this question is not appropriate, feel free to suggest an edit.]

I had the same problem transferring my project from .NET Framework 4.8 to .NET 6 (needed to have "using declarations").
Here's how I fixed mine:
Go to the affected project's settings.
Go to General and Target OS version.
Choose 1.0.19041.0 (or at the very least it must be 10.0.18362.0)
In the Supported OS version, choose any version except 7.0 or 8.0.
Build the project.
I think (I'm not sure) the issue here is UI.Xaml doesn't support Win 7 or Win 8.

Related

VS2017 - Missing .net core > 2.1 as target framework

Solution found! Took awhile, installed ALL sdks, and ALL runtimes then reinstalled latest version I wanted!
Goal,
Have netcore 2.1 or greater as a dropdown option in visual studio. I've looked at possible duplicates questions already!
Details
After the last update of visual studio 15.7 to 15.8.4 .net core 2.1 or greater has disappeared from the target framework list.
I looked at other solutions as seen below. They were not helpful as I installed every version under the sun. See below screens.
Checked below for solutions (I already looked for solutions here!):
VS2017 : Target framework drop down does not show .NET Core 2.1 option
The current .NET SDK does not support targeting .NET Core 2.1. target .NET Core 2.0 or lower or use a vs of the .NET SDK that support NET Core 2.1
Referenced screens:
UPDATE1: Removed 2.2 preview (NOT SOLVED, 2.1 is still missing)
In general, when new preview version of .NET Core 2.X appears and you are getting the error like this:
The current .NET SDK does not support targeting .NET Core 2.X
Make sure that:
You have downloaded installed SDK and runtime you need. Run command dotnet --info to see what you have installed on your machine at the moment.
You have checked the Use previews of the .NET Core SDK option here:
-> Tools -> Options -> Projects and Solutions -> .NET Core
Sometimes you might need to restart your Visual Studio after checking the option.
Note: it's always better to have the most recent Visual Studio version installed on your development machine (sometimes you might need a preview version - note a Download Preview link).
The user said, that my comment fixed the issue. So I'll post it as answer:
On the picture I see a lot of installed .Net Core SDKs, maybe Visual Studio has some issues with so many installed SDKs.
So move all old SDK folders (1.0 preview, 2.0, 2.1 except 2.1.402) out of this folder to a backup location and launch Visual Studio again.
I had this issue as well, this is what I did and it worked for me, It may or may not for you. I uninstalled everything after 2.0. I then went to this link https://www.microsoft.com/net/download and downloaded both the SDK and Run-time downloads for 2.1 then after installing them I restarted my laptop and booted up VS2017. I then went and tried creating a new web app MVC and selected .netcore 2.1 it was there.
However keep in mind .netcore 2.1 is not yet available for every template you have so check web app MVC template first if its there then you have 2.1 it just may not be available for a specific template you might be trying to use it for yet.
Hope this helps
In my case solution was: i removed few .NET Core SDK:s from "Add remove programs" and restarted visual studio. Than SDK that i need was in the list

How make Application work with 2 different versions of a DLL

if you are creating an application on a PC with .NET 4 (first release) and let it run on a second with the lastest .NET 4 Version or the first pc was update to the lastest version of .NET 4 without recompiling it. Then the application still works.
How that works?
kind regards
Newer Version of the .Net Framework are just adding functions and keeping the "old" functions the same.
If you install newer versions of the .Net Framework they include the older versions.

How does .NET Framework SDK relate to available target frameworks?

After years and years of developing C#.NET I still run into new questions.
We have a legacy project and for some dark reason a colleague of mine no longer was able to open solutions in VS2017. Long story short: the solution was finally found in uninstalling all .NET frameworks and installing 4.7.1 again.
The question that struck me then is as follows. After installing ONLY the latest .NET framework, I always thought that this install would also contain all supported target frameworks up and until this version. This is not the case, as I can only choose from the following target frameworks:
...
...
4.5
4.5.1
4.5.2
4.6
4.6.2
4.7.1
This is what I have installed (targeting packs/.NET framework SDKs).
Why is 4.6.1 missing?
Why is 4.7 missing? Or the other way around looking at what I have installed. Why is there a bunch of targeting packs available while I did not install them?
Which framework versions you can target depends on which targeting packs/SDKs you have installed on the machine, not which .NET Framework versions are installed.
You can download additional packs from .NET SDKs for Visual Studio.
Frequently when a new .NET framework version becomes available, different releases are available, some of which just include the runtime and some of which include the targeting pack. So it's possible that you've been installing the latter forms generally in the past and so not aware that they're also bundled separately.

Can't install msi package, asking for .Net framework 4

I recently upgraded my system to Windows 7 Enterprise. I have created an install package for a console application built with .Net framework 3.5 in VS2010. But when I try to install the msi on an XP machine, it gives me this warning that .Net Framework 4 is required.
Steps I tried to resolve the error:
Right click on Project and set the Target Framework to .Net Framework 3.5 in Application tab.
Right click on Project, Select Publish > Prerequisites > a) Selected .Net Framework 3.5 SP1 and b) Windows Installer 3.1
Right click on Setup Project, Prerequisites > a) Selected .Net Framework 3.5 SP1 and b) Windows Installer 3.1
Rebuild Setup Project to create msi.
All my above steps are futile since I am still getting a warning when I am installing the msi on an XP machine.
Has anybody got better idea to resolve this issue?
I think I have found the solution to this problem.
Right click on Setup Project > View > Launch Conditions. Over here, it was already referring to .Net Framework, Right click on it > Properties, change the version to .Net Framework 3.5. It solved the problem.
Install the full .NET Framework 4 on your XP machine
http://www.microsoft.com/en-us/download/details.aspx?id=17851
Dee you need to eliminate a few things. try constructing a 'blank' msi project with no dependencies in the manner described above and see if the resulting MSI requires .net4 on the target machine?
Secondly, what warning are you getting that .net4 is required? is it just the help link redirecting you to the generic .NET download page? if so, you can change this link to point to .NET3.5 SP1 specifically.

Running a c# project on windows 7

If I compile a simple(no additional libraries or assemblies) c# application, can I assume it will run on any new windows 7 machine natively or do I have to worry about end users having .Net or other libraries installed?
Windows 7 includes the .NET Framework 3.5.1 as an OS component.
This means you will get:
.NET Framework 2.0 SP2
3.0 SP2
3.5 SP1
some post 3.5 SP1 bug fixes
However, if you're using newer versions of .NET, and if you're using libraries that don't get shipped with the above, then you still need to consider packaging these up in an MSI/installer.
This page on Wikipedia has a good summary:
http://en.wikipedia.org/wiki/.NET_Framework#Versions
If this is anything more than a "quick and dirty" app, or unless you work in an area where you know exactly what the target machines look like (i.e. a corporate environment with a locked down OS image) then I'd suggest you look at building an installer and deal with pulling down the pre-requisites as appropriate. (WiX is my recommended way of doing that).
http://wix.sourceforge.net/
And WiX questions are tagged here on SO...
https://stackoverflow.com/tags/wix/
Windows 7 comes preinstalled with .NET 3.5.1 which includes 3.5 SP1, so unless you need features of .NET 4 it should work just fine.
Windows 7 ships with .Net 3.5, so, if you this .net version or lower, your application should be able to run on any Windows 7 installation
You need the appropriate .Net framework installed to match what your C# program was written with. If you don't have the correct framework, download it from microsoft.com.

Categories