So I am currently trying to install Win2D.win81 as a NuGet package via VS2015s package manager. My goal is to rewrite a simple graphing library I made to now work with a WPF control instead of winforms and benefit from the performance of Win2D vs GDI+.
To do that I made a new ClassLibrary project and added a userControl (WPF). Now I am trying to add Win2D via the package manger to the project but it keeps rejecting telling me the package doesn't target my target framework. Which wasn't that big of a deal if I haven't tried setting my project to target .Net 3.5 to 4.6.2 and any version in between and it always kept rejecting to install.
Excat error from PM:
Could not install package 'Win2D.win81 1.20.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework.
Win2D.win81 targets Windows 8.1 Store and Windows Phone 8.1 apps, which is a separate .net framework from the full .net 4.6 framework that you are trying to use.
Related
I have an application in WPF targeting .NET Core v3.1 and I'm using XamlIslands to display Windows 10 UI components. In order to use XamlIslands, I had to first migrate my app from .NET Framework to .NET Core.
I put my custom UWP components into a UWP project, which targets Win10 version 2004, min version is 1903. And in the WPF project I can reference these custom UWP components using XamlHosts.
Then, I have a Desktop Bridge project, which can package the WPF application, to be able to upload to the Microsoft Store.
The project compiles and runs correctly, I can run even the packaging project, but when I try to create a sideloaded App Package, it gives me the following error:
Project UWP is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / win-x64. Project UWP supports: uap10.0.18362 (UAP,Version=v10.0.18362)
Project UWP is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Project UWP supports: uap10.0.18362 (UAP,Version=v10.0.18362)
I tried to set the min version for the UWP app to windows 10, build 10240 (this is the oldest one), but the same error appeared (of course, with the updated uap version).
In this answer I read that maybe I should create a .NET Standard project? But there is no way to create a WPF application targeting .NET Standard.
How the error message says that the UWP app is not compatible with .netcore when I could build and run the whole solution? If it runs, why can't create an App Package?
How can I create an App Package then, which I can upload to the Store?
How to package a WPF (.NET Core) app with XamlIslands and bridge?
Please refer Host a custom WinRT XAML control in a WPF app using XAML Islands official document. And derive from your information, it looks you have not configured your solution to target a specific platform such as x86 or x64. Custom WinRT XAML controls are not supported in projects that target Any CPU.
And please don't forget edit your wpf project configuration
<AssetTargetFallback>uap10.0.19041</AssetTargetFallback>
I have make a code sample and I could make the package base on above steps, here is official code sample, you could download it and test to make a package.
When I create a new Xamarin.Forms project in Visual Studio 2017, in the project properties I can't target any other framework than
.NET standard 1.0
.NET standard 1.1
.NET standard 1.2
.NET standard 1.3
.NET standard 1.4
.NET standard 1.5
.NET standard 1.6
.NET standard 2.0
I'm trying to use a nuget package targeting .NET Framework 4.6.1 and it doesn't load because of that.
I have a warning when i add that package :
The package CHU.Xamarin.Helpers 1.0.0.1 has been restored using '.NETFramework,Version=v4.6.1' instead of target framework of the project '.NETStandard,Version=v2.0'. The package might not be totally compatible with your project.
Is there a way to target .NET Framework 4.6.1 in the project ?
If i add the nuget package anyway, i've got an error saying it is not compatible with monoandroid71 :
The package CHU.Xamarin.Helpers 1.0.0.1 is not compatible with monoandroid71 (MonoAndroid,Version=v7.1). The package CHU.Xamarin.Helpers 1.0.0.1 handles : net (.NETFramework,Version=v0.0)
The error messages are translated from French so might differs from english counterpart
NOTE: None of the following answers "how to target .NET Framework 4.6.1 for a Xamarin.Forms project". If you really, truly, need to know how to do that, and know what you are doing, and why, then search elsewhere - doing so is an advanced topic, and is no longer recommended. For cross-platform projects, stick with a .NET Standard version.
In this case, despite the question title, doing so is not the solution. Keep reading for more details.
I'm trying to use a nuget package targeting .NET Framework 4.6.1 and it doesn't load because of that.
Actually, it does load. It gives you a warning. You can probably ignore that Framework vs Standard warning - I've been ignoring a Framework 4.6.1 vs Standard 2.0 warning for over a year, without problem.
error .. saying it is not compatible with monoandroid71
This is the real problem that is stopping you.
Is there a packages.config file? If so, open it in a text editor, and search for monoandroid71. If present, then yes, this is the problem -
The packages.config mechanism contains an outdated "hint", OR you ARE targeting an older Android version, that is not compatible with the nuget you wish to use - as the message says.
Possible fix:
Target Android 8.0 or higher. In your Android project (e.g. if you named your Xamarin Forms project "App1", look in solution for the project labeled "App1.Android") / Properties / Application / Compile using Android version (Target Framework) / select Oreo or Pie.
Update all nugets to latest.
If packages.config still mentions monoandroid71, then you have outdated "hints".
Different ways to fix outdated hints in project.config. Do ONE of the following:
Rt-click on project.config in Solution pane, select "Migrate to PackageReferences". This newer mechanism doesn't rely on hints.
OR Delete project.config. Add the nugets again.
OR Manually edit project.config. Change all targetframework=monoandroidXX to be the same - whatever the highest number you find in the file. Probably monoandroid81 or monoandroid90.
OR Start all over. Latest VS 2017 version OR VS 2019. Either works fine for this purpose. New project / C# / Mobile App Xamarin Forms. Copy your source files (.cs, .xaml) to the new projects - DON'T use your old .csproj or package.config. The goal is to use all the latest build options, including PackageReferences.
I'm new in Xamarin, Xamarin.Forms and C# platform.
I'm starting the development of an app that should support Android and iOS devices. I'm using a PCL project for code sharing. Currently this project is using the profile111 because Visual Studio has selected it by default for me. But when I try to install some NuGet packages I'm getting a message saying the package is not compatible. Something like:
Could not install package 'DocsBrStandard 2.0.1'. You are trying to
install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile111', but the package does
not contain any assembly references or content files that are
compatible with that framework.
I believe this message is related with the profile I'm using, right?
So which profile should I use for my app that should support only iOS and Android devices? Is profile111 the more appropriate for this scenario?
At least, how can I identify if a package is compatible or not with my Xamarin.Forms app?
Thanks.
You need to target .NET Standard to be able to use the DocsBrStandard package. So you can't work with profile based PCL if you want to use that package.
Check out this article about targeting .NET Standard with Xamarin.Forms:
https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/
When trying to install the netmq vis nuget, I get the following error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
but the package does not contain any assembly references or content files that
are compatible with that framework. For more information, contact the package author.
The problem is that netmq depends on AsyncIO. when installing it, nuget find that the assembly is not compatible with .Net 4.5.
so nuget fail in installing AsyncIO, and then failed in installing netmq.
So I downloaded the AsyncIO Source from Github and build it locally with .Net 4.5.
After that and added the dll of AsyncIO built locally as a reference for my project.
Theoretically, NetMQ should be successfully installed with nuget. because I added the needed reference to AsyncIO.
But when trying to reinstall NetMQ, I get the same error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
but the package does not contain any assembly references or content files that
are compatible with that framework. For more information, contact the package author.
and nuget did not detect that I added 'AsyncIO 0.1.18' in my project.
How to let nuget detect that I added this reference in my project?
Have a look here:
.NET Portable profiles
Profile111 is a combination of:
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
or in other words:
portable-net45+netcore45+wpa81
So your project into which you are trying to append the NuGet targets Windows Phone 8.1 and other 2 platforms, I mention this one as the most restrictive.
Now let's have a look at the named NuGet package's source:
<ProjectGuid>{3830B7A3-0225-4FDA-B155-E085E183650C}</ProjectGuid>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
What do we have here? We can see that the project is not a PCL. It is targeting full .NET 4.0 framework which is not available on Windows Phone 8.1. And your library does target Windows Phone 8.1. See the problem?
You say that if you compile the AsyncIO targeting .NET 4.5 than you can successfully append it into your project as a reference? That's not altogether true. I mean you can append a reference to it but you cannot use it. You will see that when you try to call something from that reference.
In order to use AsyncIO from you PCL will have to build AsyncIO as a PCL targeting the same or more restrictive set of platforms. Try creating a PCL project targeting Profile111 and try compiling the AsyncIO code with it (just link the original AsyncIO source files (*.cs) into this new AsyncIO_PCL project). If you are lucky enough and the code of AsyncIO is really compatible you will be able to use that library.
Here are your steps:
Create a new project (named AsyncIO_PCL) of type PCL class library.
Pick the Profile111 platform set i.e.
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
Link all the .cs files from the original AsyncIO project save one (AssemblyInfo.cs) into the new AsyncIO_PCL project.
Set the output assembly name to the same as in original AsyncIO project.
Try building the project.
Your ability to build the AsyncIO as a PCL with the required set of supported platforms depends on AsyncIO code i.e. which API is used inside and if that API is supported by all the three platforms you are targeting.
Try clicking right-button on the project -> Properties. In the "Application" menu check the "Target Framework". It should be set to .NET Framework 4.5
I am trying to change the .net framework for a android c# app in visual studios 2013. I tried to create a new project with .net framework 4.0 but I still get an error saying that my application is targeting the 4.5 framework. Does anyone know how to force this? The reason I am doing this is that I have a nuget package that uses the 4.0 framework, however if there is a way to get that nuget package to use the 4.5 framework that is an equally valid solution.
You cannot change the .net framework for an Android app. It will always be targeting MonoAndroid.
You cannot use a NuGet package that only assemblies for the .NET framework since they may use parts of the Xamarin Android API that is not supported.
So you are left with finding another NuGet package that supports Android projects or re-compiling the source code in an Android library project so it targets MonoAndroid, which may or may not work depending on what the source code does.