我正在将 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/