iron-software / IronSoftware.System.Drawing

An open-source System.Drawing.Common replacement for .NET 5 and above on all platforms. Bringing together System.Drawing, Maui, and ImageSharp's Bitmap, Image, Font, and Shape types via an agnostic free NuGet package.
Other
114 stars 18 forks source link

Method not found: SixLabors.ImageSharp.Image SixLabors.ImageSharp.Image.Load(Byte[]) #61

Closed DjeeBay closed 1 year ago

DjeeBay commented 1 year ago

Updating from 2023.3.3 to 2023.4.4 or 2023.6.1 is throwing a method not found exception when using Image.Load((byte[])data)

Is there a knowing issue about that ? It's weird because the project compiles well and the exception is thrown before hitting the breakpoint on the Image.load line.

michael-ironsoftware commented 1 year ago

Hello @DjeeBay,

We have resolved this issue. It would depend on what version of ImageSharp you are using?

Also, what version of .NET?

DjeeBay commented 1 year ago

Thanks for the answer.

I'm not referencing directly ImageSharp. It is downloaded as a dependency of IronSoftware.System.Drawing and it is in v.2.1.3.

The project is a netstandard 2.0.

If I add manually a dependency to ImageSharp 3.x I have errors indicating that the namespace SixLabors.ImageSharp does not exist.

artem-iron commented 1 year ago

Can it be that some parts of the solution or a consuming project is targeted at .net6 or higher?

Exception you are getting happens when the code of IronDrawing that was compiled for targets >= .net 6 is then calling SixLabors.ImageSharp 2.1.3. This can happen, if your netstandard 2.0 class library is then consumed by the project targeted at .net6 or higher.

If that is the case you can make your netstandard 2.0 project target netstandard 2.0 and .net 6.0, that way the correct SixLabors.ImageSharp version will be copied to the build output folder from nuget package.

Hope this helps! Let us know if it isn't!

DjeeBay commented 1 year ago

Indeed, multi-targeting was the key to resolve the issue.

Many thanks !