Hello I'm new to Xamarin,
I'm trying to install the System.Net.Http to a Xamarin portable project using NuGet Package Manager.
However, whenever I try to download it I get this error
Could not install package 'System.Net.Http 4.3.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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
I tried every possible version of the package with no use. Could anybody provide some assistance?
Actually the way I managed to solve this problem was weird
I found a referenced assembly called
.NET --> right click View in object browser --> select System.Net.Http --> clicked add reference to the selected project
and the reference is added
Have you tried to install Microsoft.Net.Http? I use it in my PCL Xamarin Forms apps.
This can be resolved by changing the profile number for the PCL project.
Personally, i would untick all the unneeded target frameworks by going to: Project Options -> Build - General - Change Targets.
In my case i have unticked Windows Phone silverlight 8 and the profile number got changed from PCL 4.5 Profile 259 to PCL 4.5 Profile 111 as shown in this screenshot:
After doing so System.Net.Http can be added easily.
Related
I have a UWP app and a bunch of NETStandard 2.0 libraries. The libraries contains a lot of logic and communication interfaces that I am using in ASP.NetCore and Desktop WPF applications, so I am not going to change them.
I use NuGet packages in the libraries so I could reference those in NetCore and NetFramework projects as well. I would like to reference these packages in the UWP project - cause this is the whole point of this standardization concept isn't it?
For the UWP project this does not work. I have the latest Nuget package of System.ServiceModel.Primitives which is 4.5.3 (DLL version 4.5.0.3 - don't ask why) and PublicKeyToken is b03f5f7f11d50a3a - this can be referenced in every project except UWP.
Regardless of every attempt:
- I have installed the Nuget package for the project
- I have referenced the version explicitly in the CSPROJ file
- I have removed every other reference to SDK file version
But still, the UWP project looks for the dll in
C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.netcore.universalwindowsplatform\6.2.8\ref\uap10.0.15138\System.ServiceModel.Primitives.dll
That DLL has version of 4.2.1.1 and the PublicKeyToken is cc7b13ffcd2ddd51
Because the two tokens are different - binding redirects does not work - or maybe I am missing something. Does anyone have a workaround for this?
The whole solution is in VS2019 and I have the latest Win10 SDK installed 10.0.18362.1.
Thank you in advance.
EDIT: I forgot to mention, I have a repro on GitHub
You can create a separate .NET Standard project and incapsulate all your logic (and usage of System.ServiceModel.Primitives assembly) into this project. Then you can add it as a reference to the project with UWP executable.
Also you can setup a binding redirect for strongly-named assemblies by specifying codebase according to this article
I have an Xamarin.Forms project in which I want to use ZXing library for barcode scanning. However I am unable to install package ZXing.Net.Mobile and ZXing.Net.Mobile.Forms into my portable project. The exception I keep getting is as follows:
Could not install package 'ZXing.Net.Mobile 2.0.4.46'. 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.
Any ideas on how to solve this?
I took a quick look at the package contents, and the package is not completely targeting PCL Profile 111 (.NET Framework 4.5, Windows 8, Windows Phone 8.1) according to the folder name. The portable library is located in the folder:
lib/portable-net45+netcore45+wp8+UAP10.0+MonoAndroid403+MonoTouch10+Xamarin.iOS10
which is missing out wpa81 (i.e. Windows Phone 8.1 non-Silverlight) to be compatible with PCL Profile 111.
Since netcore45 and UAP10.0 are included in the folder name, I suspect that the missing wpa81 specification is just an oversight by the package authors and could be added to the folder name without problems. Of course, this has to be confirmed with the package authors, and they would need to update the NuGet package.
As a side note, I also believe the folder name is a little bit "overdone". For maximum compatibility, I think it would be better to exclude the UAP and Xamarin specifications. NuGet targets these platforms automatically if standard lib folder naming conventions are used.
If you don't need Windows Phone 8.1, as per Denis Vitez comment above, changing to Profile 7 allows you to install ZXing.Net.Mobile and ZXing.Net.Mobile.Forms.
I have created the library Staty that I want to publish via nuget for other developers to use.
I explicitly created it as Portable Class Library and restricted myself to very basic programming constructs. Now I want to publish it in a way, that others can easily use my library. I've set up my library as PCL with the following targets, which seemed to me as the most permissive platform-combination:
After completing the first version, I wanted to publish it, using Nuget GUI with the following nuget profile. I included the release-build files into the package under the portable-net4-sl4-wp7-win8 folder (I've tried portable-net45-sl5-wp8-win8 too, without any effect)
To verify, that my library is truly portable, I wanted to include it into another PCL-project, but unfortunately I'm only getting the following error: Could not install package 'Staty 1.0.0'. You are trying to install this package into a project that targets '.NETPortable, Version=v4.5, Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework.
When adding it to a regular console-application, everything works fine. It also works fine, when directly including the dll into that very same PCL-project via References -> Add Reference ... -> Browse.
So what is wrong with the way I published the package?
Additionally I tried adding folder dotnet and net45 to the nuget package with the same dlls - without any success.
In the Change Targets dialog, you are specifying .NET Framework 4.5, whereas in your NuGet setup you are targeting net4. Moreover, in the NuGet setup you are also targeting sl4 and wp7. All in all, this means that when the NuGet Manager tries to match the library path in your NuGet package with the profile of your other PCL project, it is bound to fail due to incompatibilities.
Please take a look at this list to determine in which lib sub-folder you should place your Staty.dll PCL. (The list does not explicitly specify ASP.NET Core and Xamarin targets, they are normally implicitly accounted for.) From the list you can see that the target platforms you selected in the Change Targets dialog matches Profile 259, and the NuGet target for this profile should preferably be portable-net45+netcore45+wpa81+wp8.
(If you open the Staty.csproj project file in a text editor, you can confirm that the <targetFrameworkProfile> is indeed Profile259.)
Please change the lib sub-folder name in your NuGet file to portable-net45+netcore45+wpa81+wp8, and you should then be able to reference the Staty NuGet package from your other PCL project as long this other project targets the same or a sub-set of the platforms that the Staty NuGet package is targeting.
At the moment I'm trying to launch empty app with cross-platform solution in Xamarin Studio.
I've tried make app with empty library project and shared library, both has same errors. Now unresolved problems are:
1) Build error:
Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file classes.jar doesn't exist. (XA5207) (*projectName*)
Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file libs/internal_impl-21.0.3.jar doesn't exist. (XA5207) (*projectName*)
This question didn't help me.
2) Some links says it could be because of old Mono.Android.Support.v4 component. My component version is 21.0.3.0. After clicking for update it says:
You are trying to install this package into a project that targets 'MonoAndroid,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework.
My Mono.Android assembly version is 0.0.0.0 and I dodn't know how to update it.
I've tried PCL project with PCL 4.5 - profile7. New projects builds normal, but after first project clean it gives me error about not found classes.jar file like described above. Another new PCL project still builds fine.
UPDATE
Error in PCL project occures not after clean - it occures with included Xamarin.Forms NuGet to Android project.
UPDATE
After rising target framework of android project to v4.0.3 I successfuly updated Mono.Android.Support.v4 component, but it still show me error about Please install package.
UPDATE
I'm using Windows 7 OS, same problem with all users including new user. But on another computer with Windows 8 it works. It is not a solution for me, but it can somehow help someone.
i think your java JDK and JRE not install properly and your path not set in your environment variable you must add your jdk path in that and if you are make application using cross platform then also add path SDK in your computer environmental variable. using CMD throw creating project.
I am coding a Xamarin application and I wish to add the MonoDroidToolkit as a project to my current solution. I have done this correctly, and my solution builds.
I now need to add a reference in my application to the MonoDroidToolkit project.
I have selected the "Edit References" option in the References folder. I then browse to the projects tab to select the project. The project is listed there, however I cannot select the project because of this description:
com.refractored.monodroidtoolkit (incompatible target framework:
MonoAndroid, Version=v4.2)
Here is an screenshot of the description:
I have changed the target framework of each project to be the same and also to be automatic, however, no matter what target framework I select, I cannot add the reference because of the above description.
I have done a check on the Mono.Android reference in each of my projects. In my current project, the description is version 4.1 Support and the MonoDroidToolkit is version 4.2 support.
Is this that the problem is? How can I easily update the 4.1 Support reference to be the latest? Can I get NuGet to do this, or is there another way to update all my references?
In the same solution an Android project can only reference another project if its target framework is the same version or a lower version.
You can change your project's target framework version by right clicking the project in the Solution window, selecting Options, then selecting Build - General. At the top is the Target Framework for that project. If you change that to Android 4.2 (Jelly Bean) then you should be able to reference the MonoDroidToolkit project.
The simplest way to use MonoDroidToolkit is to install it from NuGet.
Open Xamarin Studio and click check for updates. This should update your Monodroid Version