c# - Nuget版本不匹配错误出现两种解决方案

标签 c# asp.net azure asp.net-web-api azure-mobile-services

我正在为我的 Azure 移动服务开发移动后端/Web API,当我尝试调试代码时收到此消息。 Azure 配置代码存在于不同的 C# 类库中,我相信它们之间存在版本不匹配。

Additional information: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

错误来自这一行:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("photos");

以上行用于将图像 blob 上传到我的 Blob 存储。我认为这是后端和 Azure 云 API 之间的版本不匹配。您认为这个错误意味着什么?

最佳答案

半生不熟的想法:)

想法 1 在这两个项目中,打开 packages.config 文件。查看这两个文件是否引用相同版本的 Microsoft.WindowsAzure.Configuration。如果它们不同,您可以使用包管理器控制台升级或降级其中一个项目。

// update to a specific version of a package
Update-Package MyPackage -Version [an earlier or later version]

// update all packages within a project
Update-Package -Project ProjectName

Idea 2 在这两个项目中,还要检查 web.config > runtime > assemblyBinding 部分,看看是否存在有问题的 bindingRedirect Microsoft.WindowsAzure.Configuration

想法 3 要获得更全面的方法,请使用程序集绑定(bind)日志查看器。首先,从 Visual Studio 的开发人员命令提示符中运行 Fuslogvw.exe

有用的链接

Troubleshooting NuGet references

The located assembly's manifest definition does not match the assembly reference

Updating All Packages

Could not load file or assembly… NuGet Assembly Redirects

Assembly Binding Log Viewer (Fuslogvw.exe)

关于c# - Nuget版本不匹配错误出现两种解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32424280/

相关文章:

azure - parametersLink 选项不将参数传递给 templateLink

azure - 如何修复 Azure CI 上的控制台日志编码问题?

c# - 在我的应用程序中监听 MessageBox 和 Dialog 结果

asp.net - PreRenderComplete 和 SaveState 之间的时间滞后

c# - 用于验证的正则表达式模式 - 尝试压缩正则表达式中的重复模式

asp.net - 回发后属性为null-动态加载控件

c# - ASP.NET - 单元测试 MembershipProvider

Azure视频流: Custom encode format using REST API?

c# - 在 ContinueWith 中观察任务异常

c# - XDocument.ToString() 抛出 "' ', hexadecimal value 0x13, is an invalid character."异常