question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeLoadException at MagickImageCollection.AddImages with Mono on Ubuntu

See original GitHub issue

Hey,

I’m currently trying to convert pdf files using Magick.NET with Mono on Ubuntu 16.04. However, when executing this simple console application:

public static class Program
{
    public static void Main()
    {
        using (var images = new MagickImageCollection())
        {
            images.Read("Snakeware.pdf");
            for (var i = 1; i <= images.Count; i++)
            {
                images[i].Write($"Snakeware.Page.{i}.png");
            }
        }
    }
}

I get the following exception:

/usr/bin/mono /home/pettfre/Repos/typeloadexception-magicknet/Magick.Net.Error/ConsoleApplication/bin/Debug/ConsoleApplication.exe
Could not load signature of ImageMagick.MagickImage:ToBitmapSource due to: Could not load file or assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. assembly:PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 type:<unknown type> member:<none>
Could not load signature of ImageMagick.IMagickImage:ToBitmapSource due to: Could not load file or assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. assembly:PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 type:<unknown type> member:<none>

Unhandled Exception:
System.TypeLoadException: Could not resolve the signature of a virtual method
  at ImageMagick.MagickImageCollection.AddImages (System.IntPtr result, ImageMagick.MagickSettings settings) [0x00007] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ImageMagick.MagickImageCollection.AddImages (System.String fileName, ImageMagick.MagickReadSettings readSettings, System.Boolean ping) [0x00034] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ImageMagick.MagickImageCollection.Read (System.String fileName, ImageMagick.MagickReadSettings readSettings) [0x00006] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ImageMagick.MagickImageCollection.Read (System.String fileName) [0x00000] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ConsoleApplication.Program.Main () [0x00008] in <c949cae22a174c79a3837c6587272ad8>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not resolve the signature of a virtual method
  at ImageMagick.MagickImageCollection.AddImages (System.IntPtr result, ImageMagick.MagickSettings settings) [0x00007] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ImageMagick.MagickImageCollection.AddImages (System.String fileName, ImageMagick.MagickReadSettings readSettings, System.Boolean ping) [0x00034] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ImageMagick.MagickImageCollection.Read (System.String fileName, ImageMagick.MagickReadSettings readSettings) [0x00006] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ImageMagick.MagickImageCollection.Read (System.String fileName) [0x00000] in <45292dcb447e4450bb12f45cb1a5f855>:0 
  at ConsoleApplication.Program.Main () [0x00008] in <c949cae22a174c79a3837c6587272ad8>:0 

I have renamed the Magick.NET-Q8-x64.Native.dll.so to libMagick.NET-Q8-x64.Native.dll.so and am clueless as to what I am supposed to do in order to solve this problem.

Is this a problem in the library or in my setup?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pettfrecommented, Mar 13, 2018

Okay, so what I ended up doing was a post build step:

<Target Name="AfterBuild">
  <Copy SourceFiles="..\packages\Magick.NET-Q8-x64\lib\netstandard13\Magick.NET-Q8-x64.dll"
        DestinationFolder="$(TargetDir)">
  </Copy>
</Target>

This makes sure that the net40 version is replaced with netstandard13 version before (in my case) tests are executed.

Thanks a lot for your help!

0reactions
dlemstracommented, Mar 13, 2018

Thanks for coming back and explaining how you solved this 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mono TypeLoadException on XmlPreloadedResolver
I'm working on porting a Windows console app over to Linux using Mono. On my dev machine (Ubuntu), the app works like a...
Read more >
Unhandled Exception: System.TypeLoadException when ...
When I run the app under linux - mono , the app starts no problem. However I seem to be having a problem...
Read more >
System.TypeLoadException on Linux (Linux Mint 19) #2532
I experienced the same issue on Ubuntu 16.04. I had monoruntime package installed. For me, setting omnisharp.useGlobalMono to Never solved the ...
Read more >
How to install Mono from source?
So I just ran sudo make install` after having compiled on a machine. When I run it ( mono bin/SparkleShare.exe ): A type...
Read more >
Download - Stable | Mono
1 Add the Mono repository to your system. The package repository hosts the packages you need, add it with the following commands. Note:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found