错误 System.DllNotFoundException:fusion.dll 在 Azure 存储上使用 Visual Studio for Mac

Error System.DllNotFoundException: fusion.dll on Azure storage using Visual Studio for Mac

当我关注这个公会时,我正在为 Mac 使用 Visual Studio。 https://docs.microsoft.com/en-us/azure/storage/blobs/storage-dotnet-how-to-use-blobs

使用代码:

// Parse the connection string and return a reference to the storage account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString")); 

我遇到了这个异常:

System.DllNotFoundException: fusion.dll

我尝试在Visual Studio上Window做,没问题。 Mac 是 Visual Studio 的问题 你能指导我如何解决它吗? 谢谢

System.DllNotFoundException: fusion.dll

AFAIK,Fusion.dll 是一种与用于 Windows 操作系统的 Microsoft .NET Framework 关联的 DLL 文件。 Mac 的 VS 2017 可以为移动、Web、Xamarin 和 .NET Core 等构建应用程序。我假设这个问题是由使用包 Microsoft.WindowsAzure.ConfigurationManager.

引起的

请尝试使用最新版本的 WindowsAzure.Storage 并删除 Microsoft.WindowsAzure.ConfigurationManager 软件包,然后按如下方式构建您的 CloudStorageAccount 实例以缩小此问题的范围。

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("the-value-of-your-storage-connectionstring"); 

到目前为止,我找到了另一个从 Xamarin PCL 项目的 App.config 文件中获取密钥 "StorageConnectionString" 的解决方案。

您需要安装此软件包,它支持获取 App.config 文件中的键值:PCLAppConfig

然后可以通过行代码获取值:

string storageConnectionString = PCLAppConfig.ConfigurationManager.AppSettings["StorageConnectionString"];

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

为了来自 local.settings.json 文件的用户 Azure webJobStorage 连接,您可以使用

string storageConnectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage");

上一行将从 local.settings.json 文件中读取值并替换为

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString );