Unable to use ImageSharp package in a plugin on Mac

When I add the ImageSharp package in a plugin on Mac, whenever the assembly is loaded I get a System.NotSupportedException “The invoked member is not supported in a dynamic module”. See screenshot. I’ve attached the plugin to demonstrate the issue. Is there anything I can do about this in the short term?

ImageSharpTest.zip (842.1 KB)

You probably should ask the SixLabors people: https://sixlabors.com/projects/imagesharp/

Note that they also consider this package to be early-beta, so it is probably something they still need to do.

I don’t think this is a problem with their package. At least I would want to have a way to reproduce the problem outside of Rhino before complaining to them.

I think it is either a bug in the Rhino.Runtime.AssemblyResolver.CurrentDomain_AssemblyResolve function in the stack trace, or an incompatibility with the version of Mono used by RhinoMac.

This article seems relevant to what could be going on, but not having the source of CurrentDomain_AssemblyResolve I can’t say for sure: https://vagifabilov.wordpress.com/2010/07/02/net-4-0-and-notsupportedexception-complaining-about-dynamic-assemblies/

1 Like

I’ll let @stevebaer and maybe @curtisw look at this.

I couldn’t say exactly what is happening. Mac Rhino uses a custom built version of mono that is relatively old and may be the problem.

Have you tried compiling this project from source to see if that makes a difference?

ImageSharp works fine in a standalone project either in a recent version of Mono on Mac or CLR on Windows. Based on the exception traceback, it’s an issue that is happening in a Rhino event handler when an assembly is being loaded. So I don’t think anything I do to ImageSharp could change it. I guess I’ll just have to wait to see if Rhino 6 fixes the problem…

I’ve done a little digging on this, and it looks like this is because ImageSharp is built only for .NET Standard 1.1, 1.3, 2.0, and .NET Core 2.1.

According to this table, using .NET Standard requires mono 4.6 or later. Mac Rhino v5 is using mono 4.0.2.

Unfortunately, unless ImageSharp was built for .NET 4.5, it will probably not work with Mac Rhino v5.

Hope this helps!