找不到JwtSecurityTokenHandler.set_CertificateValidator方法

时间:2014-10-27 20:45:13

标签: azure-mobile-services

刚刚更新了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

4 个答案:

答案 0 :(得分:10)

我刚刚遇到同样的问题,并且已经通过

让移动服务再次运作

在VS中的程序包管理器控制台

uninstall-package WindowsAzure.MobileServices.Backend.Entity

uninstall-package WindowsAzure.MobileServices.Backend.Tables

uninstall-package WindowsAzure.MobileServices.Backend

然后

install-package WindowsAzure.MobileServices.Backend -Version 1.0.342

install-package WindowsAzure.MobileServices.Backend.Tables -Version 1.0.342

install-package WindowsAzure.MobileServices.Backend.Entity -Version 1.0.342

不知道为什么会发生这种情况

答案 1 :(得分:4)

好的,伙计们,保罗建议我终于找到了问题。 这是因为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 :(得分:2)

更新ams nuget pkg后出现同样的问题。 回滚有效,但它更像是一种解决方法,而不是解决方案。

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

答案 3 :(得分:0)

我的团队仍在调查此问题,但我还没有获得所有信息,但到目前为止,我发现更新到439并未触发此问题。您可以通过在visual studio中创建新的移动服务来验证这一点,然后进入NuGet并将Mobile Services .NET后端实体框架包更新到最新版本(439)。 更新完成后,点击F5,您会看到服务正常加载而没有任何错误。

我能够通过选择Microsoft.Owin.Security.ActiveDirectory包并将其从2.1.0更新到3.0.0来重现该问题。当然,选择NuGet中的“全部更新”选项将实现同样的目标(还有更多)。

虽然我们会继续调查确切的修复方法,但您是否可以确认升级到439而不升级到AD 3.0.0可以解决问题?