微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试使用 Unity 连接 Azure 时出现“NotImplementedException”c#

如何解决尝试使用 Unity 连接 Azure 时出现“NotImplementedException”c#

我使用的是 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) (at :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”不是我的实际连接字符串,只是隐藏敏感信息。

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。