【发布时间】:2013-07-18 03:46:05
【问题描述】:
我编写了一个简单的函数来将文件从 SkyDrive 下载到独立存储中。
public static async Task<T> DownloadFileData<T>( string fileID, string filename )
{
var liveClient = new LiveConnectClient( Session );
// Download the file
await liveClient.BackgroundDownloadAsync( fileID + "/Content", new Uri( "/shared/transfers/" + filename, UriKind.Relative ) );
// Get a reference to the Local Folder
string root = ApplicationData.Current.LocalFolder.Path;
var storageFolder = await StorageFolder.GetFolderFromPathAsync( root + @"\shared\transfers" );
// Read the file
var FileData = await StorageHelper.ReadFileAsync<T>( storageFolder, filename );
return FileData;
}
函数运行失败:
// Download the file
await liveClient.BackgroundDownloadAsync( fileID + "/Content", new Uri( "/shared/transfers/" + filename, UriKind.Relative ) );
出现错误: “在 mscorlib.ni.dll 中发生了 'System.InvalidOperationException' 类型的异常,但未在用户代码中处理
请求已经提交”
如果我将该行修改为(删除等待),则函数成功:
// Download the file
liveClient.BackgroundDownloadAsync( fileID + "/Content", new Uri( "/shared/transfers/" + filename, UriKind.Relative ) );
这是为什么呢?
谢谢
【问题讨论】:
-
“失败”是什么意思?会死机吗?有例外吗?
-
我得到的错误是:“在 mscorlib.ni.dll 中发生'System.InvalidOperationException'类型的异常,但未在用户代码中处理请求已提交”
-
您的代码是否多次提交该请求?
-
请看我对这个问题的回答。但是,您是对的,“不知何故”不止一个请求。
标签: c# windows-phone-8 async-await onedrive live-sdk