c# - 无法在 C# 中运行 Google Cloud PubSub,DLL 问题

标签 c# nuget google-cloud-pubsub

我正在将 Google Cloud PubSub 集成到我的 c# 项目中,我使用 NuGet 安装 1.0.0-beta11 ,完全没有错误。当我运行我的项目并到达使用 pubsub 的代码时,出现以下错误:

An unhandled exception of type 'System.IO.FileLoadException' occurred in 
 Google.Api.Gax.dll

Additional information: Could not load file or assembly 'Google.Apis.Auth, Version=1.21.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

NuGet 确实安装了所有依赖项,包括 Google.Apis.Auth.dll,但它是 1.27.1。我已经尝试了所有我能想到的方法,包括获取该 dll 的 1.21.0 并使用它,但没有成功。我已经能够运行 .net sample很好,没有错误。

有什么想法吗?如果您需要更多信息,请告诉我

最佳答案

好的,我找到了对 Google.Apis.Auth 1.21.0 的引用 - 它在 Grpc.Auth 中NuGet 包。

如果您只是添加对 Grpc.Auth DLL 的引用,您将遇到这种故障 - 但如果您通过 NuGet 管理所有依赖项,我希望它没问题 - 它应该为您添加程序集绑定(bind)重定向。

在不知道您的确切设置的情况下,很难说更多 - 可能是您的需要程序集绑定(bind)重定向,但应用程序控制着它们...特别是,如果您的应用程序仅引用库 DLL,就会导致问题。

作为一种变通方法,您可以手动添加程序集绑定(bind)重定向(确切的方法取决于应用程序类型)或只添加对 Google.Cloud.PubSub.V1 的引用在应用程序和库中,此时 NuGet 将为您完成所有依赖项处理。

关于c# - 无法在 C# 中运行 Google Cloud PubSub,DLL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44771019/

相关文章:

google-cloud-platform - 云pubsub轮询速度慢

c# - 代码未在我的 PDF 中绘制水平线

c# - C# 中枚举的行为

c# - .NET 标准库 - 无法加载文件或程序集 'System.Runtime.Caching'

c# - 从 Nuget 包中自动提取 native 和托管 DLL

asp.net-core - 通过 Nuget 安装时,.Net 核心解决方案中的 Nuget 内容文件不会被复制

google-cloud-platform - 如何验证 Google Cloud Endpoints 服务 URL 的所有权?

c# - FileOpenPicker 错误

c# - 如何从 mp3 中读取元数据?

google-cloud-platform - Pub/Sub - 无法提取未送达的消息