![](/img/trans.png)
[英]Problems with removable storage Hololens 2, unity and xamarin uwp
[英]NameResolutionFailure with Azure Storage Unity UWP app (works in Player)
我有一個Hololens應用程序,應從Azure存儲加載數據。 當使用WindowsAzure.Storage包轉換為unitypackage時 ,我可以在使用Unity Player時加載數據,並且在使用常規2D XAML UWP應用進行測試時,也可以在Hololens上使用該API加載數據,但是,在調試IL2CPP時項目,我得到一個“ WebException:錯誤:NameResolutionFailure”( 完整日志 )。
以下是構建簡化的測試項目的步驟:
錯誤:方法
System.Threading.Tasks.Task
1 Newtonsoft.Json.Linq.JObject :: LoadAsync(Newtonsoft.Json.JsonReader,System.Threading.CancellationToken)在目標框架中不存在。 從System.Void Microsoft.WindowsAzure.Storage.ODataErrorHelper / d__2 :: MoveNext()的Microsoft.WindowsAzure.Storage.dll引用。
這是PopulateImageGrid.cs。 可以隨意連接代碼中提供的帳戶詳細信息,因為它是一個免費帳戶,沒有敏感數據。
using System.Collections;
using System.Collections.Generic;
// using UnityEditor.PackageManager;
using UnityEngine;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.File;
using System;
public class PopulateImageGrid : MonoBehaviour {
public Transform ImageGridTile;
async void Start()
{
Debug.Log("In PopulateImageGrid.Start()");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(@"DefaultEndpointsProtocol=https;FileEndpoint=https://meshiconstorage.file.core.windows.net;AccountName=meshiconstorage;AccountKey=2Myeg/WUowehkrAY8Lgl361xxylfkMdITrVapKKVPyo9bVFqN6/uD1S66CB4oTPnnWncLubiVjioBUIT+4utaw==");
CloudFileClient cloudFileClient = storageAccount.CreateCloudFileClient();
string shareName = "meshicon-share1";
var cloudFileShare = cloudFileClient.GetShareReference(shareName);
CloudFileDirectory rootDirectory = cloudFileShare.GetRootDirectoryReference();
var fileDirectory = rootDirectory.GetDirectoryReference("images");
FileContinuationToken token = null;
int row = 0;
int col = 0;
const int width = 32;
const int height = 32;
do
{
FileResultSegment frs = await fileDirectory.ListFilesAndDirectoriesSegmentedAsync(token);
foreach (var result in frs.Results)
{
Debug.Log("In loop with " + result.ToString());
Vector3 position = new Vector3(col++ * 0.13f - 0.39f, row * 0.13f - 0.26f, 0f);
Quaternion rotation = Quaternion.identity;
Transform gridTile = Instantiate(ImageGridTile);
gridTile.transform.parent = gameObject.transform;
gridTile.localPosition = position;
gridTile.localRotation = rotation;
if (col > 6)
{
row++;
col = 0;
}
byte[] imgData = new byte[10000];
int size = await ((CloudFile)result).DownloadToByteArrayAsync(imgData, 0);
Debug.Log("Downloaded to byte[]");
Texture2D texture = new Texture2D(width, height);
byte[] realImgData = new byte[size];
Array.Copy(imgData, realImgData, size);
texture.LoadImage(imgData);
gridTile.GetComponent<MeshRenderer>().material.mainTexture = texture;
}
} while (token != null);
}
}
訣竅是要等到30秒超時后,出現NameResolutionFailure的錯誤消息,這對我來說很明顯我應該在appxmanifest中激活Internet權限。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.