[英]Live SDK assembly reference missing when developing Universal App on Windows 10
我正在使用Windows 10 SDK開發一個應用程序,我想使用Live SDK。 我正在使用VS 2015,我已經通過nuget安裝了Live SDK。
以下代碼取自MSDN示例代碼:
LiveConnectClient liveClient;
private async Task<int> UploadFileToOneDrive()
{
try
{
// create OneDrive auth client
var authClient = new LiveAuthClient();
// ask for both read and write access to the OneDrive
LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.skydrive", "wl.skydrive_update" });
// if login successful
if (result.Status == LiveConnectSessionStatus.Connected)
{
// create a OneDrive client
liveClient = new LiveConnectClient(result.Session);
// create a local file
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("filename", CreationCollisionOption.ReplaceExisting);
// copy some txt to local file
MemoryStream ms = new MemoryStream();
DataContractSerializer serializer = new DataContractSerializer(typeof(string));
serializer.WriteObject(ms, "Hello OneDrive World!!");
using (Stream fileStream = await file.OpenStreamForWriteAsync())
{
ms.Seek(0, SeekOrigin.Begin);
await ms.CopyToAsync(fileStream);
await fileStream.FlushAsync();
}
// create a folder
string folderID = await GetFolderID("folderone");
if (string.IsNullOrEmpty(folderID))
{
// return error
return 0;
}
// upload local file to OneDrive
await liveClient.BackgroundUploadAsync(folderID, file.Name, file, OverwriteOption.Overwrite);
return 1;
}
}
catch
{
}
// return error
return 0;
}
public async Task<int> DownloadFileFromOneDrive()
{
try
{
string fileID = string.Empty;
// get folder ID
string folderID = await GetFolderID("folderone");
if (string.IsNullOrEmpty(folderID))
{
return 0; // doesnt exists
}
// get list of files in this folder
LiveOperationResult loResults = await liveClient.GetAsync(folderID + "/files");
List<object> folder = loResults.Result["data"] as List<object>;
// search for our file
foreach (object fileDetails in folder)
{
IDictionary<string, object> file = fileDetails as IDictionary<string, object>;
if (string.Compare(file["name"].ToString(), "filename", StringComparison.OrdinalIgnoreCase) == 0)
{
// found our file
fileID = file["id"].ToString();
break;
}
}
if (string.IsNullOrEmpty(fileID))
{
// file doesnt exists
return 0;
}
// create local file
StorageFile localFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("filename_from_onedrive", CreationCollisionOption.ReplaceExisting);
// download file from OneDrive
await liveClient.BackgroundDownloadAsync(fileID + "/content", localFile);
return 1;
}
catch
{
}
return 0;
}
問題是即使安裝了nuget,LiveConnectClient也無法識別。 缺少其裝配參考。 當我嘗試通過添加引用手動設置它時,它仍然沒有得到解決。 (這可能只適用於Windows 8嗎?)
Live SDK信息如下圖所示:
Live SDK來自此處: https : //github.com/liveservices/LiveSDK-for-Windows
我在這里想念什么?
這可能是一個Nuget包問題,因此手動添加引用似乎可以解決問題。 您將在以下位置找到參考:
C:\\Users\\USER\\.nuget\\packages\\LiveSDK\\5.6.3\\WindowsXAML\\MicrosoftLive.dll
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.