c# - Why am I getting "'System.Array' does not contain a definition for 'AsBuffer'" with this WinRT code? -



c# - Why am I getting "'System.Array' does not contain a definition for 'AsBuffer'" with this WinRT code? -

according this, next code can used convert byte array bitmapimage:

public static async task<bitmapimage> bytearraytobitmapimage(this byte[] bytearray) { if (bytearray != null) { using (var stream = new inmemoryrandomaccessstream()) { await stream.writeasync(bytearray.asbuffer()); var image = new bitmapimage(); stream.seek(0); image.setsource(stream); homecoming image; } } homecoming null; }

however, get, "'system.array' not contain definition 'asbuffer' , no extension method 'asbuffer' accepting first argument of type 'system.array' found (are missing using directive or assembly reference?)"

is "var stream" assignment vague (implicit typing) , need specify particular info type "stream" var? other system.array?

maybe this, "windows store apps succinctly" clue: buffers/byte arrays—system.runtime.interopservices.windowsruntime. windowsruntimebufferextensions: extension methods in class provide ways moving between .net byte arrays , contents of winrt buffers, exposed ibuffer implementations.

...but if is, that's not plenty info me know it. instead of "tmi" it's "nei" (not plenty information).

the problem compiler isn't finding extension method asbuffer(). create sure have reference namespace system.runtime.interopservices.windowsruntime, i.e.

using system.runtime.interopservices.windowsruntime;

you need add reference appropriate dll, if haven't already:

namespace: system.runtime.interopservices.windowsruntime

assembly: system.runtime.windowsruntime (in system.runtime.windowsruntime.dll)

c# windows-runtime bytearray bitmapimage system.array

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -