System.IO.FileNotFoundException Could not load assembly System.Drawing - android-webview

I meet this error in a Xamarin.forms project using WebView and local html base url:
Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'System.Drawing, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't
exist in the Mono for Android profile? Nom de fichier :
'System.Drawing.dll' à
Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference
reference, ReaderParameters parameters) à
Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1
assemblies, AssemblyDefinition assembly, Boolean topLevel) à
Xamarin.Android.Tasks.ResolveAssemblies.Execute() Almicantarat.Droid
I read that:
System.IO.FileNotFoundException: Could not load assembly System.Web in Mono for Android
but I don't know which client's source code I should compile.
I read that:
Could not load file or assembly 'System.Drawing, Version=4.0.0.0
but in my project, there is no reference to System.Drawing !!
See my references:
my android project references

Solved:
-> Close the solution
-> Delete all contents of the Packages folder (all the DLL's referenced through Nuget)
-> Restart the solution
-> Build (this will cause Nuget to get all DLL's again based on the packages.config)

Related

Nuget SDK missing when Scaffolding a class Using Ardalis clean architecture template

Hi I trying Ardalis Clean Architecture.
Running VS 2022 and dotnet 6.
I am trying to scaffold a class and get the following error in the code generator phase:
"Scaffolding failed.
SDK Resolver Failure: "The NuGet-based SDK resolver failed to run because NuGet assemblies could not be located. Check your installation of MSBuild or set the environment variable "MSBUILD_NUGET_PATH" to the folder that contains the required NuGet assemblies. System.IO.FileLoadException: Could not load file or assembly 'NuGet.Versioning, Version=6.0.0.278, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)To see more information, enable tracing by setting environment variable 'codegen_trace' = 1.
File name: 'NuGet.Versioning, Version=6.0.0.278, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
---> System.IO.FileLoadException: Could not load file or assembly 'NuGet.Versioning, Version=6.0.0.280, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at Microsoft.Build.Shared.MSBuildLoadContext.Load(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.NuGetAbstraction.TryParseNuGetVersion(String version, Object& parsed)
at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.TryGetNuGetVersionForSdk(String id, String version, SdkResolverContext context, Object& parsedVersion)
at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)" C:\Workspace\VSProjects\CleanArchitecture\xxx..."
Any one have a clue what is missing?

Using Accord.Imaging in UWP

(apologies for beginner question) I am trying to use Accord.Net Imaging function in an UWP windows 10 App. Any function I try gives me an error:
The type 'Bitmap' is defined in an assembly that is not referenced. You must add a reference to assembly 'CoreCompat.System.Drawing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.The type 'Bitmap' is defined in an assembly that is not referenced. You must add a reference to assembly 'CoreCompat.System.Drawing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
although I included Using System.Drawing (which includes Bitmap)
UnmanagedImage unmanagedImage = UnmanagedImage.FromByteArray(bytes);
If you're using NuGet, you can install the following package to get System.Drawing, and thus access to the Bitmap class: https://www.nuget.org/packages/CoreCompat.System.Drawing.v2/5.2.0-preview1-r131
Note that this is a prerelease version, so you'll need to check the box that says "Include prerelease" next to the search bar if using the Visual Studio NuGet GUI.

error while referencing sqlite-net-pcl package in Xamarin forms Android project

I am getting the following error when i attempt to reference the sqlite-net-pcl package in the Android project of Xamarin forms project. I get this error when building in release mode but debug mode seems to be fine.
I am using
sqlite-net-pcl 1.4.118
Xamarin.Forms 2.4.0.282
Xamarin.Android.Support.* 25.4.0.2
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'SQLite-net, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'SQLite-net.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) CouchPortfolioApp.Android
You should reference sqlite-net-pcl in your target platform project as well.
I had a similar problem with sqlite-net-pcl and .NET Standard 2.0 when I was building in debug mode. I changed the linker and cleaned and rebuilt the solution (I even deleted the bin and obj folder).
In the properties of the project -> android options -> linking -> "SDK assembly Only"
In my case in release worked with "None"
Android Options:

Must I rebuild Nunit 2.6.2 to use it with .net 4.0?

When I try to run some tests with:
nunit-console.exe <mydll> /framework:net-4.0
I am rewarded with:
Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly 'nunit-console-runner, Version=2.6.2.12296,
Culture=neutral, PublicKeyToke n=96d09a1eb7f44a77' or one of its
dependencies. The system cannot find the file specified. File name:
'nunit-console-runner, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' at
NUnit.ConsoleRunner.Class1.Main(String[] args)
There is no file named nunit-console-runner anywhere.
When I leave off the /framework, all is well. However, I need the /framework as my goal is to debug as mixed-mode test failure on a 64-bit system.

How can I load WPFToolkit assembly in Powershell

I have installed WPF Toolkit:
Location: C:\Program Files\WPF Toolkit\v3.5.40320.1\WPFToolkit.dll
Name: WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Type: Library
I can load it by full path:
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\WPF Toolkit\v3.5.40320.1\WPFToolkit.dll")
But can't load by assembly name:
[System.Reflection.Assembly]::LoadWithPartialName("WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
[System.Reflection.Assembly]::Load("WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
What is a solution?
Loading by assembly name doesn't work because the WPFToolkit assembly is neither in GAC nor in the PowerShell directory. There are several options:
load it by path
add it to the GAC
change powershell.exe.config to look
in the WPF Toolkit directory
handle the AppDomain.AssemblyResolve
event (not particulary easy in
PowerShell V1)