【问题标题】:Azure Blob upload error: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0Azure Blob 上传错误:无法加载文件或程序集 'System.Threading.Tasks.Extensions,版本 = 4.2.0.0
【发布时间】:2021-01-27 13:09:33
【问题描述】:

我有麻烦了。我已经构建了一个应用程序,可以通过 SDK Azure.Storage.Blobs 在 Azure 上上传文件。 我的应用程序是一个独立的 DLL,它可以被 Windows 运行程序捕获,该程序可以通过使用反射的线程启动进程。 当我通过 Winform 应用程序 Test 测试我的应用程序时,一切都很完美:我可以创建我的 Blob 容器、连接到 azure 并上传我的 Blob。

但是当我的 DLL 被另一个程序启动时,我有一个错误: 无法加载文件或程序集“System.Threading.Tasks.Extensions,Version=4.2.0.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”或他对 Azure.Storage.Blobs.BlobServiceClient 的依赖项之一(字符串 connectionString,BlobClientOptions 选项)à AzureCloud.GetBlobContainer(字符串 pBlocContainer) 创建 BlobServiceClient 时弹出错误。

我检查了我所有的 dll 和依赖项都在“复制本地”到“真”中。我试图在启动我的 dll 的其他应用程序上安装插件。没有任何效果,我找不到任何可行的解决方案。 下面是上传文件的代码:

 public async Task<string> UploadFile(FileInfo file, string pBlocContainer)
    {
        try
        {
            var documentName = file.Name;

            var container = GetBlobContainer(pBlocContainer);
            BlobClient blockBlob = container.GetBlobClient(documentName);

            using (var fileStream = File.OpenRead(file.FullName))
            {
                await blockBlob.UploadAsync(fileStream);
            }
            return blockBlob.Uri.ToString();
        }
        catch(Exception e)
        {
            throw new Exception(e.Message + e.InnerException);
        }
    }
 public static BlobContainerClient GetBlobContainer(string pBlocContainer)
    {
        // Pull these from config
        var blobStorageConnectionString = mConnectionString; 
        var blobStorageContainerName = pBlocContainer; 

        // Create blob client and return reference to the container
        BlobServiceClient blobServiceClient = new BlobServiceClient(blobStorageConnectionString);
        BlobContainerClient container = blobServiceClient.GetBlobContainerClient(blobStorageContainerName);
        return container;

    }

我使用 nuget Azure.Core 1.8.1

提前感谢您的帮助。如果需要其他信息告诉我..

【问题讨论】:

  • 有关信息,我还尝试将 dll 复制到我的 SysWow64 和我的 System32 文件夹中的 toruble 中。但它并没有更好的工作......

标签: c# azure azure-blob-storage


【解决方案1】:

如果有人遇到这个问题,我设法通过在主进程 .config 文件中编写 Azure 的程序集声明和重定向来解决它,即使这个过程与它无关......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多