1

我已将我的 ImageSharp 引用迁移到版本 1.0.0-dev000692。现在我不能再加载图像了。我得到了你可以在下面看到的异常。

致电

byte[] data = GetImage();
var image = Image.Load(data);

该函数在 ASP.Net Core (2.0) 应用程序中调用

例外

Method not found: '!0 System.ReadOnlySpan`1.get_Item(Int32)'.

at SixLabors.ImageSharp.Formats.Bmp.BmpImageFormatDetector.IsSupportedFileFormat(ReadOnlySpan`1 header)
at SixLabors.ImageSharp.Formats.Bmp.BmpImageFormatDetector.DetectFormat(ReadOnlySpan`1 header)
at SixLabors.ImageSharp.Image.<>c__DisplayClass0_0.<InternalDetectFormat>b__0(IImageFormatDetector x)
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.TryGetLast[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at SixLabors.ImageSharp.Image.InternalDetectFormat(Stream stream, Configuration config)
at SixLabors.ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
at SixLabors.ImageSharp.Image.WithSeekableStream[T](Stream stream, Func`2 action)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Byte[] data)
at work4all.Server.Api.Core.Controllers.FileController.ResizeBenutzerBild(Byte[] data, Int32 maxHeight, Int32 maxWidth, String filename) in D:\DEV\VSTS-work4all\work4all Server\work4all.Server.Api.Core\work4all.Server.Api.Core\Controllers\FileController.cs:line 211
4

2 回答 2

0

这不是 ImageSharp 的问题,而是当前 CoreClr 预览的问题。

https://github.com/dotnet/coreclr/pull/14727

您必须使用 .Net Core 2.1 的预览版,现在恢复到 2.0 即可解决。

更新

自 beta4 以来,该解决方案将在 .NET Core 2.1 上运行

于 2018-02-05T00:14:57.457 回答
0

我也遇到了这个问题。您是否尝试过更新到 SixLabors.ImageSharp.Drawing beta 4?它可能需要对您的图像处理逻辑进行一些重构工作,但它设法解决了我的问题,即使我也在 Core 2 上运行。

于 2018-07-20T21:15:42.993 回答