Visual Studio for Mac操作Azure Storage遇fusion.dll缺失异常求修复指引
Hey there, let's get this fusion.dll error sorted out for you. The root cause here is that fusion.dll is a Windows-only system assembly used by .NET Framework, and your current code relies on older Azure Storage libraries tightly coupled to Windows-specific components. Since Visual Studio for Mac focuses on cross-platform .NET (Core/.NET 5+), this mismatch is triggering the error. Here are actionable fixes to resolve it:
1. Upgrade to the Modern Azure Storage SDK (Recommended)
The old WindowsAzure.Storage package (which includes CloudStorageAccount and CloudConfigurationManager) is legacy and not optimized for cross-platform use. Replace it with the official modern Azure.Storage.Blobs package built for cross-platform .NET:
- Uninstall the
WindowsAzure.StorageNuGet package from your project. - Install the
Azure.Storage.Blobspackage via NuGet. - Replace your connection string code with this cross-platform compatible version:
This approach uses .NET's cross-platformusing Azure.Storage.Blobs; using Microsoft.Extensions.Configuration; // Load configuration from appsettings.json (or your preferred config source) var configBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); IConfiguration config = configBuilder.Build(); // Retrieve the storage connection string string storageConnectionString = config["StorageConnectionString"]; // Initialize the modern Blob service client (replaces CloudStorageAccount) BlobServiceClient blobServiceClient = new BlobServiceClient(storageConnectionString);IConfigurationsystem instead of Windows-onlyCloudConfigurationManager, eliminating the dependency on fusion.dll.
2. Verify Your Project Targets a Cross-Platform .NET Framework
Make sure your project isn't targeting .NET Framework (a Windows-only runtime):
- Right-click your project in Visual Studio for Mac → Properties → Application tab.
- Under Target framework, select a cross-platform version like .NET 6/7/8 or .NET Core 3.1.
3. Clean and Rebuild to Clear Cached Artifacts
Sometimes stale build files can cause unexpected dependency issues:
- Go to Build → Clean Solution.
- Manually delete the
binandobjfolders from your project directory. - Go to Build → Rebuild Solution.
- Restore NuGet packages by right-clicking the project → Restore NuGet Packages.
Why This Happens on Mac but Not Windows
CloudConfigurationManager from the old Azure SDK uses .NET Framework-specific APIs that depend on fusion.dll—a file that doesn't exist on macOS. Windows Visual Studio works because it runs on an OS where this DLL is natively present. The modern Azure Storage SDK removes these Windows-specific ties, making it fully compatible with macOS.
内容的提问来源于stack exchange,提问作者Tony Pham

