问题描述
我想在我的类库创建StorageFile实例...
I am trying to create an instance of StorageFile in my class library...
var localFolder = ApplicationData.Current.LocalFolder;
StorageFile destinationFile = await localFolder.CreateFileAsync(destination, CreationCollisionOption.GenerateUniqueName);
VS11不建说:'等待'要求类型'Windows.Foundation.IAsyncOperation有一个合适的方法GetAwaiter。是否缺少using指令为系统?
VS11 is not building say: 'await' requires that the type 'Windows.Foundation.IAsyncOperation' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
显然我使用.NET 4.5作为目标,我引用的Windows组件...
不知道为什么在这个MetroStyle code的工作,但在类库不建...我如何创建一个类库的Storagefile实例?在此阶段,如果在一个异步方式创建的文件并不重要...
obviously I am using .net 4.5 as target and I am referencing Windows Assemblies...not sure why this code work in MetroStyle but does not build in a class library... How can I create an instance of Storagefile in a class library??? at this stage it is not important if the file is created in an async way...
请让我知道你的想法...
斯泰利奥
pls let me know your thoughts...Stelio
推荐答案
什么工作对我来说是手工添加TargetPlatformVersion
What worked for me is to "manually" add the TargetPlatformVersion
<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
在项目组中添加以下
and in Item group add the following
<ItemGroup>
<Reference Include="System.Runtime.WindowsRuntime" />
<Reference Include="System.Runtime" />
<Reference Include="Windows" />
</ItemGroup>
那么项目应normaly编译。
Then the project should compile normaly.
这篇关于StorageFile异步使用在非Metro应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!