Skip to content

Add support for .NET Core 2.1 #459

Description

@msmolka

Description

I've recently upgrade my system to ASP.NET Core 2.1.0-preview2-30045
This libraries are using System.Memory 4.5.0-preview2-26202-05

After update I'm not able to load image any more:
using (var image = Image.Load<Rgba32>(pictureDataBytes, new PngDecoder()))

this is throwing exception:

System.MethodAccessException: Attempt by method 'SixLabors.ImageSharp.Formats.Png.Filters.SubFilter.Decode(System.Span`1<Byte>, Int32)' to access method 'System.Span`1<System.Byte>.DangerousGetPinnableReference()' failed.
   at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.DecodePixelData[TPixel](Stream compressedStream, ImageFrame`1 image)
   at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.Decode[TPixel](Stream stream)
   at SixLabors.ImageSharp.Formats.Png.PngDecoder.Decode[TPixel](Configuration configuration, Stream stream)
   at SixLabors.ImageSharp.Image.<>c__DisplayClass43_0`1.<Load>b__0(Stream s)
   at SixLabors.ImageSharp.Image.WithSeekableStream[T](Stream stream, Func`2 action)
   at SixLabors.ImageSharp.Image.Load[TPixel](Stream stream, IImageDecoder decoder)
   at SixLabors.ImageSharp.Image.Load[TPixel](Byte[] data, IImageDecoder decoder)

Steps to Reproduce

use System.Memory 4.5.0-preview2-26202-05 and try to load PNG image.

System Configuration

  • ImageSharp version: 1.0.0-beta0002
  • Other ImageSharp packages and versions: 1.0.0-beta0002
  • Environment (Operating system, version and so on): Windows 10
  • .NET Framework version: 4.6.2
  • Additional information:

Activity

  1. changed the title [-]System.MethodAccessException: Attempt by method 'SixLabors.ImageSharp.Formats.Png.Filters.SubFilter.Decode(System.Span`1<Byte>, Int32)' to access method 'System.Span`1<System.Byte>.DangerousGetPinnableReference()' failed.[/-] [+]System.MethodAccessException: 'System.Span`1<System.Byte>.DangerousGetPinnableReference()' failed.[/+] on Feb 7, 2018
  2. antonfirsov commented on Feb 7, 2018

    @antonfirsov
    Member

    @msmolka the 4.5 version of System.Memory used by .NET Core 2.1 is not yet available on NuGet, thus we are not able to support it in our beta ImageSharp package published on NuGet.

    This means that we only support .NET Core <= 2.0 at the moment. I hope 2.1 reaches preview state soon, so we can add support for it.

  3. changed the title [-]System.MethodAccessException: 'System.Span`1<System.Byte>.DangerousGetPinnableReference()' failed.[/-] [+]Add support for .NET Core 2.1[/+] on Feb 7, 2018
  4. msmolka commented on Feb 7, 2018

    @msmolka
    Author

    Thanks, I understand
    I have web core app, which is using this library. I need to add SignalR, which is on preview right now, which then breaks this lib.

    Fighting with manual binding redirects and codeBase, a lot of manual work. Had to switch off automatic binding redirects.

    Maybe it will finally work. Started looking promising.

  5. msmolka commented on Feb 8, 2018

    @msmolka
    Author

    Just a comment if somebody will need to work with version 2.1 and ImageSharp
    Binding redirects are working in .NET Core (in unit tests as well).
    This issue can be workaround by disabling
    <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>

    Then get latest 4.4.0 System.Memory from nuget
    put it in some folder and specify all redirects manually and create entry for previous version:

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Memory" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
            <codeBase version="4.0.0.0" href="dlls\4.4.0\System.Memory.dll" />
            <codeBase version="4.0.1.0" href="System.Memory.dll" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
    
  6. antonfirsov commented on Feb 27, 2018

    @antonfirsov
    Member

    Looks like we've got a green light to fix this. Here's what we need to do:

    • Update the package reference
    • adopt a few API changes like span.DangerousGetPinnableReference() -> MemoryMarshal.GetReference(span)
    • Add netcoreapp2.1 target to the test project
    • Configure at least one of our CI platforms to also run tests on 2.1

    The last one is not critical, but I'm pretty much into testing everything that's considered to be a feature.

    @JimBobSquarePants should we add this to the beta-3 milestone?

  7. JimBobSquarePants commented on Feb 28, 2018

    @JimBobSquarePants
    Member

    @antonfirsov Yeah, let's add it, it should be a quick win.

  8. added this to the 1.0.0-beta3 milestone on Feb 28, 2018
  9. antonfirsov commented on Feb 28, 2018

    @antonfirsov
    Member

    According to gitter news a PR is actually being prepared for this :)

  10. pfeigl commented on May 4, 2018

    @pfeigl

    What's the current status on this? .NET core 2.1 is meanwhile in preview2-final and the release slowly gets onto the horizon. Just searched through the PRs and couldn't find the mentioned one.

  11. JimBobSquarePants commented on May 4, 2018

    @JimBobSquarePants
    Member

    The nightlies support preview 2 so you should be able to run with the latest there.

  12. antonfirsov commented on May 24, 2018

    @antonfirsov
    Member

    I think #577 closes this. 2.1 should work fine in nightlies.
    appveyor test execution will be added with .NET Core 2.1 RC2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions