C# 在Mono 6.4+;上对Autofac`RegisterAppicController()`的IdentityServer 3调用失败;带“TypeLoadException”`
我们已经将IdentityServer3 2.5.4与Mono 4.8一起使用了一段时间,运行在Ubuntu和MacOS上 我们已经升级到Mono 6.6,现在启动时出现异常:C# 在Mono 6.4+;上对Autofac`RegisterAppicController()`的IdentityServer 3调用失败;带“TypeLoadException”`,c#,mono,autofac,identityserver3,C#,Mono,Autofac,Identityserver3,我们已经将IdentityServer3 2.5.4与Mono 4.8一起使用了一段时间,运行在Ubuntu和MacOS上 我们已经升级到Mono 6.6,现在启动时出现异常: System.TypeLoadException: Could not load type of field 'Microsoft.Owin.Security.DataProtection.DpapiDataProtector:_protector' (0) due to: Could not res
System.TypeLoadException: Could not load type of field
'Microsoft.Owin.Security.DataProtection.DpapiDataProtector:_protector' (0)
due to: Could not resolve type with token 01000107 from typeref
(expected class 'System.Security.Cryptography.DpapiDataProtector'
in assembly 'System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
assembly:System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
type:System.Security.Cryptography.DpapiDataProtector
member:(null)
at (wrapper managed-to-native) System.RuntimeTypeHandle.type_is_assignable_from(System.Type,System.Type)
at System.RuntimeTypeHandle.CanCastTo (System.RuntimeType type, System.RuntimeType target) [0x00000] in <285579f54af44a2ca048dad6be20e190>:0
at System.RuntimeType.IsAssignableFrom (System.Type c) [0x00020] in <285579f54af44a2ca048dad6be20e190>:0
at Autofac.Integration.WebApi.RegistrationExtensions.<RegisterApiControllers>b__0 (System.Type t) [0x00000] in <03d9eb8289e046799e444fc1f976e306>:0
[...]
at IdentityServer3.Core.Configuration.Hosting.AutofacConfig.Configure (IdentityServer3.Core.Configuration.IdentityServerOptions options) [0x004ef] in <03d9eb8289e046799e444fc1f976e306>:0
System.TypeLoadException:无法加载字段的类型
“Microsoft.Owin.Security.DataProtection.DpapiDataProtector:\u protector”(0)
原因:无法从typeref解析带有标记01000107的类型
(应为类“System.Security.Cryptography.DpapiDataProtector”
在程序集中“System.Security,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”)
程序集:System.Security,版本=4.0.0.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a
类型:System.Security.Cryptography.DpapiDataProtector
成员:(空)
at(包装器管理到本机)System.RuntimeTypeHandle.type_是可分配的(System.type,System.type)
在:0中的System.RuntimeTypeHandle.CanCastTo(System.RuntimeType类型,System.RuntimeType目标)[0x00000]处
在0中的System.RuntimeType.IsAssignableFrom(System.Type c)[0x00020]处
在Autofac.Integration.WebApi.RegistrationExtensions.b__0(System.Type t)[0x00000]中:0
[...]
在:0中的IdentityServer3.Core.Configuration.Hosting.AutofacConfig.Configure(IdentityServer3.Core.Configuration.IdentityServerOptions选项)[0x004ef]处
(为了可读性而编辑。)
当遇到异常时,Autofac正在扫描IdentityServer3.dll
程序集以注册其WebApi控制器
Microsoft.Owin.Security.DataProtection.DpapiDataProtector
是此程序集的私有成员(根据monop-p
),我猜这就是扫描找到它的原因
我尝试过4.8和6.6之间的其他单声道版本;它只适用于Mono 6.4及以上版本
其他版本:
- Autofac 3.5.2
- Autofac.Owin 3.1.0
- Autofac.WebApi2 3.4.0
- Autofac.WebApi2.Owin 3.3.0