【问题标题】:Getting "NotImplementedException" when attempting Azure connection with Unity (c#)尝试与 Unity 进行 Azure 连接时出现“NotImplementedException”(c#)
【发布时间】:2021-09-18 04:49:42
【问题描述】:

我正在使用 Unity 2019.3.6f1。我创建了一个简单的 DLL,用于连接到 Azure 并上传文件。但是,当我调用此 DLL 以尝试连接到 Azure blob 存储时,我得到以下堆栈跟踪:

NotImplementedException:方法或操作未实现。 System.Net.Http.HttpClientHandler.get_MaxConnectionsPerServer () (在 :0) Azure.Core.Pipeline.ServicePointHelpers.SetLimits (System.Net.Http.HttpMessageHandler messageHandler) (在 :0) Azure.Core.Pipeline.HttpClientTransport.CreateDefaultClient () (在 :0) Azure.Core.Pipeline.HttpClientTransport..ctor () (在 :0) Azure.Core.Pipeline.HttpClientTransport..cctor () (在 :0) 重新抛出为 TypeInitializationException:类型初始化器 'Azure.Core.Pipeline.HttpClientTransport' 引发异常。 Azure.Core.ClientOptions..ctor () (在 :0) Azure.Storage.Blobs.BlobClientOptions..ctor (Azure.Storage.Blobs.BlobClientOptions+ServiceVersion 版本)(在 :0) Azure.Storage.Blobs.BlobServiceClient..ctor (System.String connectionString,Azure.Storage.Blobs.BlobClientOptions 选项)(在 :0) Azure.Storage.Blobs.BlobServiceClient..ctor (System.String 连接字符串)(在:0) Cineon.UnityToAzureConnection+d__1.MoveNext () (在 :0) --- 从先前抛出异常的位置结束堆栈跟踪 --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (在 :0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+c.b__6_0 (System.Object 状态) (在 :0) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke()(在 :0) UnityEngine.UnitySynchronizationContext:ExecuteTasks()

这是我的 DLL 代码(符合this Microsoft quickstart guide):

public class UnityToAzureConnection
{
    private readonly static string m_connectionString = "CENSORED";

    public static async void CreateConnection(string _path, string _fileName)
    {
        BlobServiceClient blobServiceClient = new BlobServiceClient(m_connectionString);
        BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync("imagetest");

        BlobClient blobClient = containerClient.GetBlobClient(_fileName);
        using (FileStream _fs = File.Open(Path.Combine(_path, _fileName), FileMode.Open))
        {
            await blobClient.UploadAsync(_fs, true);
        }
    }
}

我只是调用这个 DLL 的 CreateConnection 方法并传入我的“Application.dataPath”和一个文件名。但是,然后我得到了上述异常。

我已将所有其他需要的 DLL 从项目构建文件夹中提取到插件文件夹中,所以我不确定为什么会发生这种情况。

任何帮助将不胜感激。

请注意,我刚刚开始走出自己的舒适区,所以我希望我的帖子符合 StackOverflow 的问题标准。

[P.S.] 显然“CENSORED”不是我的实际连接字符串,只是隐藏敏感信息。

更新 29/05/2021 我已确认我的连接代码在简单的 .net 控制台应用程序中使用时确实有效(但是,我确实必须将容器名称调整为全部小写)。此错误仅在 Unity 中发生。同样,我们将不胜感激。

【问题讨论】:

    标签: c# unity3d dll azure-blob-storage dllimport


    【解决方案1】:

    正如我在这里提到的,尝试一次。 如果你有较低版本的 Unity,Azure.Core 版本。 1.19.0 可能会更好。

    https://forum.unity.com/threads/attempting-to-connec-to-azure-blobs-results-in-notimplementedexception.1117705/

    【讨论】:

      猜你喜欢
      • 2016-05-07
      • 2022-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-21
      • 2012-04-20
      • 1970-01-01
      相关资源
      最近更新 更多