none
Mysterious 'AsBuffer' extension method... RRS feed

  • Question

  • There is a method named AsBuffer() an extension method defined here.

    It's defined in the assembly System.Runtime.WindowsRuntime.dll

    However in a simple store app on Windows 8 using VS 2012, I cannot add this assembly, it is simply not listed when I try Add Reference (in fact NO standard assemblies get listed, VS 2012 implies 'all' needed assemblies are already added!)

    Calling AsBuffer() on a byte[] will therefore not compile.

    Can anyone shed light on this?

    The app has just two references:

    1. .Net for Windows Store apps
    2. Windows

    These were added when the empty grid app was created in VS 2012.

    The whole windows 8/app store/.Net 4.5/VS 2012 world is very different and often bewildering even for seasoned .Net developers.

    Thanks

     

     

     



    Wednesday, February 20, 2013 8:57 PM

Answers

  • Hi,

    Perhaps the '.NET for Windows Store Apps' includes the 'System.Runtime.WindowsRuntime.dll' assembly. Did you write a using directive?

    using System.Runtime.InteropServices.WindowsRuntime;

    Best regards

    • Marked as answer by Captain Kernel Thursday, February 21, 2013 2:10 PM
    Thursday, February 21, 2013 1:20 PM

All replies

  • Hi,

    Perhaps the '.NET for Windows Store Apps' includes the 'System.Runtime.WindowsRuntime.dll' assembly. Did you write a using directive?

    using System.Runtime.InteropServices.WindowsRuntime;

    Best regards

    • Marked as answer by Captain Kernel Thursday, February 21, 2013 2:10 PM
    Thursday, February 21, 2013 1:20 PM
  • Hi,

    Perhaps the '.NET for Windows Store Apps' includes the 'System.Runtime.WindowsRuntime.dll' assembly. Did you write a using directive?

    using System.Runtime.InteropServices.WindowsRuntime;

    Best regards

    Very good - that worked - I did however expect "Resolve" to work when I right clicked on the unresolved name, if the required assembly is already referenced then 'Resolve' should always be available.

    This may be a bug in how VS 2012 handles unresolved names...

    Thanks again!

    Cap'n

    Thursday, February 21, 2013 1:53 PM