我在我们的网站中实现了 Google 身份验证,其中客户端是 Angular,后端是 IIS 上的 .NET C#。我在客户端启动该过程并获得访问令牌。令牌必须转发到基于 .NET 的后端。在后端,我将 Google.Apis.Auth 1.51.0 库称为 NuGet 包。我使用那里的工具验证令牌。在 Visual Studio 调试模式下从源代码测试时,它可以完美运行,但在我发布版本后无法在 IIS 下运行。
错误消息是:“无法加载文件或程序集 'Google.Apis.Auth, Version=1.51.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'。”
我检查了依赖项,它们位于具有正确版本的本地文件夹中。(Google.Apis.dll、Google.Apis.Core.dll、Google.Apis.Auth.dll、Google.Apis.Auth.PlatformServices.dll 和 Newtonsoft.Json.dll)一般的解决方案是使用 bindingRedirect。我尝试在web.config中将0.0.0.0-1.51.0.0范围设置为新版本1.51.0.0,但是没有效果。像这样:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.51.0.0" newVersion="1.51.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我尝试使用 Google.Apis、Google.Apis.Core 和 Google.Apis.Auth.PlatformServices 执行此操作,但没有成功。我在配置标签中没有命名空间。我在有和没有 publicKeyToken 的情况下都试过了。
我想问一下你有没有遇到过这个问题?你知道该怎么做吗?我非常感谢您的帮助。