System.IO.FileNotFoundException Could not load assembly System.Drawing

jddjdd USMember ✭✭

Hello,

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, reference to System.Drawing is coming from mono.android which is a Xamarin component!

Should I compile mono.android myself ? where could I find it ? does Xamarin provide it ?

See my references attached.

Thanks

Tagged:

Best Answer

Answers

  • DnyaneshwarDnyaneshwar USMember ✭✭

    @jdd tried above solution but still getting following error.
    Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'

  • jddjdd USMember ✭✭

    @Dnyaneshwar
    First, close VS and update the android SDK.
    Then, did you delete all the files from the "packages" folder in your solution?
    You should also delete all the files and folders in the "bin>debug" folders of your projects.
    Last, restart VS and Rebuild your project.

  • DnyaneshwarDnyaneshwar USMember ✭✭

    @jdd thanks

  • johanksonjohankson SEInsider, University ✭✭

    Still experiencing this issue... Any hints...

  • jddjdd USMember ✭✭

    did you try to update android sdk and java ?

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • MarkRadacz.7953MarkRadacz.7953 USInsider, University, Developer Group Leader ✭✭

    XS Ent 6.1.5 (build 0) on Mac: updated to the latest XF 2.3.3.193 (same happens with 2.3.4.22-nightly) and on Android getting build error trying to run on v6.0
    getting exception System.IO.FileNotFoundException: Could not load assembly 'System.Drawing
    already tried deleting and restoring all packages, bin and lib folders etc...
    here is the full exception:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'System.Drawing.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in :0
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in :0
    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x00180] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0
    at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x001ec] in <2fdd3551eb6c4960b69522c8a0cd7aa3>:0 (UHCNV.APP.MYSMA.Droid)

  • VijayPawar.0297VijayPawar.0297 USMember ✭✭

    I had same kind of issue when I updated components in project [ Nuget Packages ] so. then I downloaded latest required dll files [I needed 3 ] from
    here

  • AmirAbdiAmirAbdi USMember ✭✭

    The suggested solution did not work.
    I found the source of the problem in using UItest for my android Xamarin project. As soon as I removed the reference to the UITest project from the android project, the project was built with no problem.

    I still don't know how to add the UITest without running into the same exception.

  • mostafamahmoudmostafamahmoud USMember
    edited August 2017

    I have Same problem .

  • FilipLarssonFilipLarsson SEMember ✭✭

    Thank you VijayPawar.0297, I did what you said.

    I downloaded System.Drawing.dll and System.Configuration.dll and added them in my bin/debug folder

  • JakobGnnerJakobGnner USMember ✭✭
    edited November 2017

    Ok I have delteted the contents from the bins folders, restarted vs and rebuild the solution, but the error is the same:

  • JakobGnnerJakobGnner USMember ✭✭

    @JakobGnner said:
    Ok I have delteted the contents from the bins folders, restarted vs and rebuild the solution, but the error is the same:

    Haha! I solved it by updating all the Xamarin.Android.Support Nuget Packages, because the Xamarin.Android.Support.Fragment.dll needs the assemblies to be at least version 26.1, which they have now!

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    In my case, I was not able to upgrade to 26.1.0.1. I ended up staying at 25.4.0.2 for Xamarin.Android.Support.* and also reverting NetStandard to 1.4. just so I would not get the missing file error and then I could compile again.

  • DavidHedelinDavidHedelin USMember ✭✭

    @AmirAbdi You found a way to solve it? I'm also trying to use UITest nuget with app center.

  • DavidHedelinDavidHedelin USMember ✭✭
    edited February 23

    If you get this error while trying to use Xamarin.UITest with microsoft center (app center): System.IO.FileNotFoundException: Could not load assembly 'System.Drawing.........

    You are only supposed to have the Xamarin.UITest nuget package in the UITest project. Not in the main project, iOS or android.

  • ssilvassilva USMember

    I'm working on Windows with Xamarin.Forms netstandard2.0 and I had some error like that after adding a project reference.

    The solution for me was... adding the reference "System.Configuration.dll" (..Windows\Microsoft.NET\Framework64\v4.0.30319\System.Configuration.dll) to the .Net Standard project.

  • Brian_SnoddyBrian_Snoddy USUniversity ✭✭

    Same for me. I added a project reference. Got the error. Added the reference "System.Drawing.dll" (..Windows\Microsoft.NET\Framework64\v4.0.30319\System.Drawing.dll) to the Android project and it was solved.

  • Liêm_NguyễnLiêm_Nguyễn USMember ✭✭✭

    @jdd said:
    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)

    Exactly which folder? bin/obj ?????

  • miguelahcmiguelahc Member

    @ssilva said:
    I'm working on Windows with Xamarin.Forms netstandard2.0 and I had some error like that after adding a project reference.

    The solution for me was... adding the reference "System.Configuration.dll" (..Windows\Microsoft.NET\Framework64\v4.0.30319\System.Configuration.dll) to the .Net Standard project.

    this works for me. thanks

  • AditkothariAditkothari USMember ✭✭

    @ssilva said:
    I'm working on Windows with Xamarin.Forms netstandard2.0 and I had some error like that after adding a project reference.

    The solution for me was... adding the reference "System.Configuration.dll" (..Windows\Microsoft.NET\Framework64\v4.0.30319\System.Configuration.dll) to the .Net Standard project.

    This worked for me also ..Thanks

Sign In or Register to comment.