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

Unable to run Google Cloud PubSub in c#, DLL problems(无法在 C# 中运行 Google Cloud PubSub,DLL 问题)
本文介绍了无法在 C# 中运行 Google Cloud PubSub,DLL 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working on integrating Google Cloud PubSub into my c# project, I used NuGet to install 1.0.0-beta11, no errors at all. When I run my project and when it reaches the code that uses pubsub, I get the following error:

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 示例很好,没有错误.

NuGet did install all the dependencies including Google.Apis.Auth.dll, but it's 1.27.1. I have tried everything I could think of, including grabbing 1.21.0 of that dll and using that, but no success. I have been able to run the .net sample just fine with no error.

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

Any thoughts? Let me know if you need more info

推荐答案

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

Okay, I've found the reference to Google.Apis.Auth 1.21.0 - it's in the Grpc.Auth NuGet package.

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

If you just add a reference to the Grpc.Auth DLL, you'll get this kind of failure - but if you manage all the dependencies via NuGet, I'd expect it to be okay - it should add assembly binding redirects for you.

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

Without knowing your exact setup, it's quite tricky to say more than that - it could be that your library needs assembly binding redirects, but the application is in control of them... and in particular, if your application only has a reference to the library DLL, that would cause the problem.

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

As a workaround, you could either manually add the assembly binding redirects (the exact way of doing that will depend on the application type) or just add a reference to Google.Cloud.PubSub.V1 in the application as well as the library, at which point NuGet will do all the dependency handling for you.

这篇关于无法在 C# 中运行 Google Cloud PubSub,DLL 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)