JwtSecurityTokenHandler.set_CertificateValidator方法未找到。

7

我刚刚更新了Azure移动服务的许多程序包,现在出现了“方法未找到”的错误。目前似乎还没有其他人报告这个问题。有没有想法是哪个程序包需要降级?或者有其他的解决方法吗?

[MissingMethodException: Method not found: 'Void System.IdentityModel.Tokens.JwtSecurityTokenHandler.set_CertificateValidator(System.IdentityModel.Selectors.X509CertificateValidator)'.]
       Microsoft.WindowsAzure.Mobile.Service.Security.Providers.GoogleLoginProvider..ctor(HttpConfiguration config, IServiceTokenHandler tokenHandler) +0
       lambda_method(Closure , Object[] ) +174
       Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +419

    [DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(System.Web.Http.HttpConfiguration, Microsoft.WindowsAzure.Mobile.Service.Security.IServiceTokenHandler)' on type 'GoogleLoginProvider'. ---> Method not found: 'Void System.IdentityModel.Tokens.JwtSecurityTokenHandler.set_CertificateValidator(System.IdentityModel.Selectors.X509CertificateValidator)'. (See inner exception for details.)]
       Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +999
       Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +589
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
       Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +63
       Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +201
       Autofac.Core.Resolving.InstanceLookup.Execute() +262
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
       Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
       Autofac.Features.Collections.<>c__DisplayClass6.<RegistrationsFor>b__1(IComponentRegistration cr) +60
       System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
       System.Linq.Buffer`1..ctor(IEnumerable`1 source) +335
       System.Linq.Enumerable.ToArray(IEnumerable`1 source) +77
       Autofac.Features.Collections.<>c__DisplayClass4.<RegistrationsFor>b__0(IComponentContext c, IEnumerable`1 p) +256
       Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +191
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
       Autofac.Core.Resolving.InstanceLookup.Execute() +158
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
       Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +60
       Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +111
       Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +279
       Autofac.Core.Container.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +57
       Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +175
       Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +250
       Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters) +72
       Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType) +63
       Microsoft.WindowsAzure.Mobile.Service.Config.AutofacDependencyScope.GetServices(Type serviceType) +269
       System.Web.Http.DependencyScopeExtensions.GetServices(IDependencyScope services) +172
       System.Web.Http.DependencyScopeExtensions.GetLoginProviders(IDependencyScope services) +41
       Microsoft.WindowsAzure.Mobile.Service.Config.OwinAppBuilder.ConfigureAuthentication(IAppBuilder appBuilder, HttpConfiguration config) +379
       Microsoft.WindowsAzure.Mobile.Service.Config.OwinAppBuilder.Configuration(IAppBuilder appBuilder) +70
       Microsoft.WindowsAzure.Mobile.Service.<>c__DisplayClass5.<ConfigureOwin>b__4(IAppBuilder appBuilder) +40
       Microsoft.WindowsAzure.Mobile.Service.Config.StartupOwinAppBuilder.Configuration(IAppBuilder appBuilder) +234

一般来说,在您的后端项目中更新软件包并不是一个好主意,因为我们的托管环境中有特定的版本,当您进行更新时可能会发生不兼容的情况。 - lindydonna
4个回答

10

我刚刚遇到了同样的问题,通过以下步骤使移动服务重新工作:

在VS中的“程序包管理器控制台”中执行以下操作:

卸载“WindowsAzure.MobileServices.Backend.Entity”程序包

卸载“WindowsAzure.MobileServices.Backend.Tables”程序包

卸载“WindowsAzure.MobileServices.Backend”程序包

然后

安装“WindowsAzure.MobileServices.Backend - Version 1.0.342”程序包

安装“WindowsAzure.MobileServices.Backend.Tables - Version 1.0.342”程序包

安装“WindowsAzure.MobileServices.Backend.Entity - Version 1.0.342”程序包

不确定为什么会发生这种情况


我仍然遇到相同的错误,但是使用了Azure AD。尝试了几个版本,包括342和405,但都没有成功。这个问题在其他地方有没有得到反馈? - Damien Pontifex
我也遇到了同样的问题。这完全与System.IdentityModel.Tokens.Jwt有关,从342以上的任何版本都会引起问题。MobileServices团队只是没有正确引用这个dll。 - Adam
1
只安装WindowsAzure.MobileServices.Backend.Entity,因为它会安装其他的 :) - saramgsilva

4
大家好,感谢Paul提供的建议,我终于找到了问题所在。
问题是由于System.IdentityModel.Tokens.Jwt 4.0.0包版本引起的。
事实上,将Microsoft.Owin.Security.ActiveDirectory包从2.1.0更新到3.0.0会导致Jwt包从3.0.2更新到4.0.0。
解决方法是将ActiveDirectory恢复为2.1.0,Jwt恢复为3.0.2,然后按F5键并享受AMS 439。
install-package System.IdentityModel.Tokens.Jwt -version 3.0.2

2

在更新ams nuget包后,我也遇到了同样的问题。回滚操作虽然可行,但只是一种权宜之计。

编辑:你可以回滚到405版本。


你找到解决方案了吗? - Erik Z
还没有。已经在MSDN论坛和Git问题中发布,但是到目前为止还没有得到任何答复。 - JeremyBP

0

我的团队仍在调查此问题,我还没有所有信息,但到目前为止,我观察到更新到439不会触发该问题。您可以通过在Visual Studio中创建一个新的移动服务,然后进入NuGet并将Mobile Services .NET Backend Entity Framework包更新到最新版本(439)来验证这一点。 更新完成后,按F5键,您应该看到服务正常加载而没有任何错误。

我能够通过选择Microsoft.Owin.Security.ActiveDirectory包并将其从2.1.0更新到3.0.0来复制问题。当然,在NuGet中选择“全部更新”选项也会实现同样的效果(以及更多)。

虽然我们继续研究确切的修复方法,但您能否确认升级到439而不升级到AD 3.0.0是否解决了问题?


我没有升级Microsoft.Owin.Security.ActiveDirectory,但我升级了Microsoft.Owin.Cors和Microsoft.Owin,然后出现了问题。还有其他包需要检查吗?我也升级了JWT包。 - BoB

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接