Xamarin - Could not load assembly 'PCLStorage.Abstractions - c#

After adding the FlurlHttp Nuget package to my PCL project my app will no longer deploy to my emulator due to an assembly loading error
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'PCLStorage.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'PCLStorage.Abstractions.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at
Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() InfoSupport.AV.MobileClient.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1347
The build system is also reporting conflicts :
There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes". (TaskId:77)
2> "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not. (TaskId:77)
There was a conflict between "PCLStorage.Abstractions, Version=0.9.6.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64" and "PCLStorage.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64". (TaskId:142)
2> "PCLStorage.Abstractions, Version=0.9.6.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64" was chosen because it was primary and "PCLStorage.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64" was not. (TaskId:142)
These errors appeared after adding the Microsoft.Build.Async (1.0.168), Microsoft.Bcl.Build(1.0.21), Microsoft.Net.Http(2.2.29), Microsoft.Bcl (1.1.10) nuget packages to my
PCL project, Xamarin forms project and Xamarin Droid project.
In addition, the Nuget packages Xamarin.Forms.Maps (v2.1.0.6508) and Xamarin.Forms (v2.1.0.6508-pre3) are used.

Adding the nuget package PclStorage v1.0.2 to the PCL project resolves both warnings and the deployment error.
I'm not sure why this dependency is there.

Related

Found conflicts between different versions of "Microsoft.Bcl.AsyncInterfaces"

I have a netstandard2.0 library that is used by net5.0 applications
One of packages used by the library references Microsoft.Bcl.AsyncInterfaces 5.0.0
But I get this warning for every application:
47>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2203,5):
warning MSB3277: Found conflicts between different versions of "Microsoft.Bcl.AsyncInterfaces" that could not be resolved.
There was a conflict between "Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
"Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not.
References which depend on "Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll].
C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll
Project file item includes which caused reference "C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll".
C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll
References which depend on "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [].
Please note that "Project file item includes which caused reference" is not a project but the dll itself. My guess is that 1.0.0 version is used by compiler with .net standard to provide some core async functionality
But how can I get rid of this message? There seems to be no binding redirection for .Net 5.0

Wrong referenced assembly

Getting the following error when attempting to build my solution. I'm fairly certain I've done it on this machine before but it's been many months. I'm not sure what might have changed in the meantime.
Assembly uses 'Microsoft.AnalysisServices.AdomdClient, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' which has a higher version than referenced assembly 'Microsoft.AnalysisServices.AdomdClient' with identity 'Microsoft.AnalysisServices.AdomdClient, Version=8.0.700.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
I have attempted to remove every mention of 8.0.700.0 from my computer via the SSDT (un)installer and manual deletion of files and registry entries and gacutil. The project is configured to use 10.0, but I cannot figure out how it even knows that a 8.0.700.0 version exists in the first place.
As far as I know, nothing remains in the registry, or the GAC, or the assemblies folders for version 8.0.700.0.
Any idea what is going on here?
Currently in the GAC
$ gacutil /l | grep Microsoft.AnalysisServices.AdomdClient,
Microsoft.AnalysisServices.AdomdClient, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.AnalysisServices.AdomdClient, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.AnalysisServices.AdomdClient, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.AnalysisServices.AdomdClient, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL

How to resolve .net version conflicts

I have the following warning messages during build.
No way to resolve conflict between "System.ComponentModel.Annotations,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and
"System.ComponentModel.Annotations, Version=4.0.10.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a". Choosing
"System.ComponentModel.Annotations, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
We have around 70 C# projects (net framework 462, net core, net standard). Are there any automated tools to fix the version conflicts problem?

Conflict between System, Version=4.0.0.0 and System, Version=2.0.5.0 in ServiceStack.Interfaces

I am trying to resolve build warnings but I cannot get past this one. I am targeting .Net 4.6.2, but it appears that ServiceStack.Interfaces is targeting a lower version? In the detailed output:
There was a conflict between "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
1> "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.
1> References which depend on "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll].
1> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll
1> Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll".
Then followed by many regular assemblies which looks good, then the conflict:
1> References which depend on "System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" [].
1> C:\Code\Trunk\packages\ServiceStack.Interfaces.4.5.6\lib\portable-wp80+sl5+net45+win8+wpa81+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll
1> Project file item includes which caused reference "C:\Code\Trunk\packages\ServiceStack.Interfaces.4.5.6\lib\portable-wp80+sl5+net45+win8+wpa81+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll".
1> ServiceStack.Common, Version=4.5.6.0, Culture=neutral, processorArchitecture=MSIL
1> ServiceStack.Interfaces, Version=4.0.0.0, Culture=neutral, PublicKeyToken=e06fbc6124f57c43, processorArchitecture=MSIL
1> ServiceStack.Redis, Version=4.5.6.0, Culture=neutral, processorArchitecture=MSIL
So it appears that ServiceStack.Interfaces is causing the problem, yet I need to reference it. Am I referencing it wrong in some way? How can I resolve the warning?
ServiceStack.Interfaces is a plain PCL library that's just built with the System.Runtime.Serialization it references using VS2017's new MSBuild format. It doesn't explicitly reference any version, the PCL build decides on what version it uses.
Once .NET Standard 2.0 and .NET Core 2.0 is released we'll be merging .NET Standard libraries together into the main ServiceStack NuGet packages in a major v5 release of ServiceStack that will replace the PCL libraries with .NET Standard which will resolve this warning, but we'll need to wait for v5 before we make any structural changes.

MSBuild conflict between mscorlib 4.x and mscorlib 2.x

I was investigating a build failure recently and saw a warning about conflicts between assemblies. I dug deeper and MSBuild told me this:
There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.`
My solution contains several console applications, lots of class libraries and ASP.NET application. We build on .NET 4.5.2.
Should I be concerned?
When using PCL libraries it is better add Microsoft.Bcl.Build Nuget package which will attempt to resolve this issue for your.
Also you should investigate dependencies of your class libraries and find where you depends on the PCL library.

Categories