无法在C#,DLL问题中运行Google Cloud PubSub [英] Unable to run Google Cloud PubSub in c#, DLL problems

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

问题描述

我正在将Google Cloud PubSub集成到我的c#项目中,我使用NuGet安装

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.我已经尝试了所有我能想到的一切,包括获取1.21.0的dll并使用该dll,但没有成功.我已经能够运行 .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的引用-它位于

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管理 all 依赖项,我希望它可以-它应该为您添加程序集绑定重定向.

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.

在不知道您确切的设置的情况下,要讲的更多技巧是非常棘手的-它可能是您的需要程序集绑定重定向,但是 application 可以控制它们...尤其是如果您的应用程序仅对库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#,DLL问题中运行Google Cloud PubSub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆