XmlWriter error (with AsStreamForWrite())

2014-06-06  籽藤 

'Windows.Storage.Streams.IRandomAccessStream' does not contain a definition for 'AsStreamForWrite' and no extension method 'AsStreamForWrite' accepting a first argument of type 'Windows.Storage.Streams.IRandomAccessStream' could be found (are you missing a using directive or an assembly reference?)

遇到这个extension method问题,在网上找的各种答案都是要加命名空间:

using System.Runtime.InteropServices.WindowsRuntime;

http://social.msdn.microsoft.com/Forums/windowsapps/en-US/5025f758-36bd-4af1-95f1-a3a2003d2044/xmlwriter-error-with-asstreamforwrite?forum=winappswithcsharp

但真正需要添加的命名空间是:

using System.IO;

http://msdn.microsoft.com/en-us/library/system.io.windowsruntimestreamextensions.asstreamforwrite(v=vs.110).aspx

这个简单的命名空间问题折腾了我近一个小时,因为我明明安装了.net framework 4.5.1, 然而本地的Reference Assemblies目录(C:\Program Files\Reference Assemblies\Microsoft\Framework)中只有v3.0和v3.5两个文件夹。而这个method是4.5版本中的,所以我误以为VS安装framework有问题,需要额外add reference files.

嘻,问题解决了,可以继续折腾咯~

368°/3689 人阅读/0 条评论 发表评论

登录 后发表评论