Xamarin build fails to load assembly I'm not even referencing - c#

I have a Xamarin.Android project loaded in VS 2017. When I build the project I get error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.IdentityModel.Tokens.Jwt, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Perhaps it doesn't exist in the Mono for Android profile?
System.IdentityModel.Tokens.Jwt is not referenced by this project, i.e. it's not under References, nor packages.config. It's not listed in Nuget Package Manager's list of installed packages.
How can I figure out why the build is trying to load that assembly?
Why is the build even trying to load assemblies, shouldn't that be the responsability of the application, not of the build? (Not saying it does, but an app may "know" how to load its assemblies using a custom ResolveEventHandler, the build can't "know" that.)

Related

How to run tests on a net6.0-windows project

I have two projects in my solution:
A Windows UI automation project migrated from .NET Framework 4.x to net6.0-windows. Uses System.Windows.Automation only available on net6.0-windows
A Tests project with these Nuget packages installed: Microsoft.NET.Test.Sdk 17.3.0; MSTest.TestAdapter 2.2.10; MSTest.TestFramework 2.2.10. This project references the project above. The target framework is net6.0-windows.
I can't continue since I encounter the following errors:
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Installed Microsoft.TestPlatform 17.3.0 but assemblies aren't copied to the bin folder.
The tests work on net6 target framework, but the UI Automation project can't use that target. Thank you in advance!

warning MSB3258 on mscorlib for shared reference

So I am currently working on a .NET Framework project that is referencing a DLL made by another dev I am working with that I will call "random.dll". My project is targeting .NET 3.5. I have no compiler errors in my project but when I attempt to build while referencing this DLL I receive a warning during the build saying the reference could not be resolved:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3258: The primary reference "random.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
This build warning causes my build to fail when attempting to reference classes in that reference.
I then zipped up my project and sent it to the dev who was able to build it themselves with no changes to the project. I am trying to figure out what could possibly be different on only my machine that would cause this issue.
Change your .net framework to 4.0.0

Could not load file or assembly 'PCLAppConfig' in UWP project

I have a Xamarin project with iOS, Android and UWP projects.
I have installed the version 1.0.1 from nuGet in all three projects and in .net standard's one.
The iOS and Android projects works fine but when I run the UWP project this error is triggered:
System.IO.FileLoadException: 'Could not load file or assembly 'PCLAppConfig, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
The compile works fine, only at runtime the error come.
How can I solve this error?
EDIT
Maybe I found the problem but I cannot resolve it.
From nuGet I have installed the latest version, the 1.01 but the version of the DLL is the 0.4.0.
Maybe UWP read the 0.4.0 version and triggers the error?

C# - Xamarin.Froms.Build.Task.GetTaskAbi - error

I have been getting the below error everytime I try to build a Xamarin Forms App.
Does anyone have a solution to this error.
I have uninstalled and reinstalled VS2017 two times.
I have deleted all the folder to do a clean install.
Severity Code Description Project File Line Suppression State
Error The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly C:\Users\Regardt.nuget\packages\xamarin.forms\3.0.0.446417\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. App2.Android
Download and install .NET Framework 4.7.1 or 4.7.2 then seemed to resolve the issue.
Microsoft .NET Framework 4.7.1 (Offline Installer):
https://www.microsoft.com/en-us/download/details.aspx?id=56116
Microsoft .NET Framework 4.7.2 offline installer for Windows:
https://support.microsoft.com/en-us/help/4054530/microsoft-net-framework-4-7-2-offline-installer-for-windows

System.Data.Linq in netstandard20

I have a netstandard20 project that references a .Net 4.6 Project, all compiles and runs except where I call any functionality in the .Net 4.6 project, I get the following error.
FileNotFoundException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
In VS 2017, in the project explorer under Dependancies / SDK / Microsoft.NETCore.App I can see System.Data.dll and System.Data.Common.dll but no reference to System.Data.Linq.dll, I am assuming this is my problem and it has not been pulled in.
How do I get my project to include System.Data.Linq.dll?
If I include C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.Linq.dll I get the following error
BadImageFormatException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
I was able to solve my need to use System.Data.Linq in a .NET Standard 2.0 library by using the Mindbox.Data.Linq NuGet package.
After installing it you should be able to use the System.Data.Linq namespace just like you could when writing for .NET Framework!
System.Data.Linq is not part of .NET Standard 2.0 and .NET Core 2.0 and therefore cannot be used on that platform.
Even tough you have been able add a reference to a .NET 4.6 project via the compatibility shims, it fails at runtime because of a feature that is not available on the target runtime

Categories