Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image.Load(byte[]) throws Method not found System.ReadOnlySpan.get_Item(Int32) #447

Closed
0xGeorgii opened this issue Jan 23, 2018 · 31 comments

Comments

@0xGeorgii
Copy link

Description

Image.Load on method below throws Method not found: '!0 System.ReadOnlySpan1.get_Item(Int32)'.` with the stack trace

   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 SourceProvider.Network.SrcLoader.<DownloadImageAsync>d__1.MoveNext() in D:\GitHub\ImageBlendingAlgorithms\ImageBlendingAlgorithms\SourceProvider\Network\SrcLoader.cs:line 26
--- End of stack trace from previous location where exception was thrown ---
   at DesktopUI.MainWindow.<StartButtonHandle>d__11.MoveNext() in D:\GitHub\ImageBlendingAlgorithms\ImageBlendingAlgorithms\DesktopUI\MainWindow.xaml.cs:line 96

Steps to Reproduce

        public static async Task<Image<Rgba32>> DownloadImageAsync(uint x, uint y)
        {
            var data = await DownloadSrcAsync(x, y);
            return Image.Load(data);
        }
  • ImageSharp version: 1.0.0-beta0002
  • Environment (Operating system, version and so on): win10-x64
  • .NET Framework version: netcore2.1

1

@dlemstra
Copy link
Member

Looks like this is related to this issue: dotnet/coreclr#14727. Seeing that exception in one of the comments.

@JimBobSquarePants
Copy link
Member

@dlemstra Yeah, that looks like the issue, good work.

@GeorgePlotnikov It looks like you are also using the preview of NETCore 2.1 Have you tried the 2.0 release? The library should be stable against that.

I'm not sure what (or even if) we will have to do when 2.1 reaches RTM but I'll ask around.

@0xGeorgii
Copy link
Author

@dlemstra, @JimBobSquarePants thanks guys for the quick response, fixed via moving to netcore2.0

coenm added a commit to coenm/EagleEye that referenced this issue Feb 27, 2018
…age of Span<byte>. Increased timeout of test.
@molinch
Copy link

molinch commented Mar 6, 2018

@JimBobSquarePants @dlemstra I have the same issue on .NET 4.6.2 do you have any advise in that case?

@antonfirsov
Copy link
Member

@molinch what version of System.Memory does does your project refer to? It's current (4.5) API is not backwards compatible with the previous 4.4 preview.

I assume your project is referencing the 4.5 preview, while ImageSharp beta has been compiled against 4.4. In that case the solution is easy however: just check out our latest nightlies, we moved to 4.5 with #482 .

@molinch
Copy link

molinch commented Mar 6, 2018

In fact I was not using System.Memory before, it has been pulled when I got the latest prerelease for ImageSharp. So now I have System.Memory 4.5.0-preview1-26216-02

My assembly bindings got updated for some assemblies: System.Runtime, System.Runtime.Extensions, System.Reflection and some got added: System.Numerics.Vectors, System.Runtime.CompilerServices.Unsafe, System.Memory, System.Diagnostics.Tracing

@molinch
Copy link

molinch commented Mar 6, 2018

Sorry I understand what you meant now 👍
I will try to downgrade System.Memory then, I'd rather not use a nightly in production

@antonfirsov
Copy link
Member

antonfirsov commented Mar 6, 2018

NuGet is pulling the newest version by default as far as I understand.

@JimBobSquarePants this is a very serious issue. All new users + all users doing a NuGet update will encounter it. Fortunately beta-3 is coming very soon.

@molinch
Copy link

molinch commented Mar 6, 2018

I agree for new users it's really a pain, even though it's Microsoft's fault since they unlisted their package...
For reference I ended up doing in my projects:
Update-Package -ProjectName MyProjectName -Id System.Memory -Pre -Version 4.4.0-preview2-25405-01
And I needed to change assembly bindings

@JimBobSquarePants
Copy link
Member

I will try to downgrade System.Memory then, I'd rather not use a nightly in production

Tut tut... You shouldn't be using a beta in production! 😉

Progress is moving swiftly with beta3 and we should have it out in the next few days - a week max.

We will be moving your cheese around though with lots of namespace changes (sensible ones). We should have API docs though to help you migrate.

@molinch
Copy link

molinch commented Mar 7, 2018

Yes you are right, I meant "future release" which will eventually go to production.
The thing is there are not so many alternatives when you need to process images on ASP.NET: System.Drawing shouldn't be used, WPF libs should of course not be used, ... What's left?

I think that I will anyway revert back to System.Drawing temporarily, even though that's a bad idea, since I added ImageSharp I have issues related to .NETStandard/MSBuild: https://github.com/dotnet/corefx/issues/25773#issuecomment-350000563

Once again it's nothing from you, ImageSharp is really great and the API is a breaze, but it's just too many issues just to make a simple thumbnail

@JimBobSquarePants
Copy link
Member

We'll get there soon. It's difficult to build something like this when the goalposts are moved so often upstream.

but it's just too many issues just to make a simple thumbnail

Nothing simple about a thumbnail Have you seen the code in that class. Resizing it hard! 😄

@rusty21
Copy link

rusty21 commented Mar 12, 2018

I'm attempting to use this library on Xamarin Android and I am seeing the exception happening as well. I have a NetStandard library targeting 2.0 and the issue still persists. Is there something wrong that I'm doing?
using (Image<Rgba32> image = SixLabors.ImageSharp.Image.Load(path))
using the beta0002 version of SixLabors.ImageSharp

@JimBobSquarePants
Copy link
Member

What version of System.Memory are you using? Have you tried the steps above?

#447 (comment)

@rusty21
Copy link

rusty21 commented Mar 12, 2018

The System.Memory package version was already at 4.4.0-preview2-25405-01. I'm using visual studio for mac if that makes any difference?

@molinch
Copy link

molinch commented Mar 12, 2018

So your local Nuget is 4.4.0-preview2-25405-01 ?
If so try also changing your assembly bindings

@rusty21
Copy link

rusty21 commented Mar 12, 2018

I don't know what it means to change assembly bindings.

@molinch
Copy link

molinch commented Mar 12, 2018

In your app.config or web.config, if you have an entry for System.Memory under , then it should be so:

<dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>

@rusty21
Copy link

rusty21 commented Mar 12, 2018

The my netstandard project doesn't have an app.config just a single class with the SixLabors.ImageSharp library installed. This project is then referenced by a Xamarin.Android project.

screen shot 2018-03-12 at 10 23 12 am

@molinch
Copy link

molinch commented Mar 12, 2018

Do you have an app.config in your Xamarin.Android project?
If yes then add the binding redirect there.

@rusty21
Copy link

rusty21 commented Mar 12, 2018

That didn't seem to help. I've attached a sample solution for a xamarin android project the demonstrates the error. Created with visual studio 2017 on a pc. Perhaps you could take a look and tell me where I went wrong.

ImageSharpTest.zip

@JimBobSquarePants
Copy link
Member

I would grab the nightlies from our MyGet feed. That should work fine.

@MaklaCof
Copy link

@JimBobSquarePants Is there any plan/release date when using ImageSharp with .NET Core 2.1 will be supported? At least basic scenarios like LoadingImage from FileName.

@JimBobSquarePants
Copy link
Member

@JimBobSquarePants Is there any plan/release date when using ImageSharp with .NET Core 2.1 will be supported? At least basic scenarios like LoadingImage from FileName

Don't be that guy. .NET Core 2.1 isn't even released yet.

anagura added a commit to anagura/wedding-photo-sharing that referenced this issue Apr 10, 2018
@lennartquerter
Copy link

Updating to beta04 solved this problem :) Thank you !

@boradakash
Copy link

Any plan/release for supporting .Net Core2.1?

@JimBobSquarePants
Copy link
Member

We already support the release candidate with beta 4. I’ve tested the final release against it and it works

@boradakash
Copy link

boradakash commented Jun 14, 2018

Ah okay, Thanks
I am using version: 1.0.0-alpha9-00194. May be that's why.

Does beta 4 supports all of the feature that 1.0.0-alpha9 supports, because I can't see Resize() method on Image(in beta.4) Or am I missing something?

your help would be greatly appreciated !!

@JimBobSquarePants
Copy link
Member

Yes of course. You should probably read the api documentation linked from our readme.

@antonfirsov
Copy link
Member

@boradakash:

That's a super-old buggy version, we had many fixes/changes since that. Please read this article for the major API change introducing Mutate/Clone:
https://sixlabors.com/blog/announcing-imagesharp-beta-1/

@boradakash
Copy link

@antonfirsov
Cool thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants