Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法加载类型“Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider”_C#_Asp.net Identity_Enterprise Library - Fatal编程技术网

C# 无法加载类型“Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider”

C# 无法加载类型“Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider”,c#,asp.net-identity,enterprise-library,C#,Asp.net Identity,Enterprise Library,我最近尝试在4.6.1框架中使用asp.net标识实现身份验证。 在安装了所有必需的软件包之后,我在运行应用程序时遇到以下错误 无法加载类型 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider 卸载与identity相关的所有包后,同一应用程序可以正常工作 完整堆栈跟踪如下所示 [TypeLoadException:无法加载类型 'Microso

我最近尝试在4.6.1框架中使用asp.net标识实现身份验证。 在安装了所有必需的软件包之后,我在运行应用程序时遇到以下错误

无法加载类型 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider

卸载与identity相关的所有包后,同一应用程序可以正常工作

完整堆栈跟踪如下所示

[TypeLoadException:无法加载类型 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider' 从程序集“Microsoft.Practices.EnterpriseLibrary.Common”, 版本=6.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35'] System.Reflection.CustomAttribute.\u CreateCaObjectRuntimeModule pModule,IRuntimeMethodInfo pTor,字节**ppBlob,字节*pEndBlob, Int32*pcNamedArgs+0 System.Reflection.CustomAttribute.CreateCaObjectRuntimeModule模块, IRuntimeMethodInfo-ctor,IntPtr&blob,IntPtr blobEnd,Int32& namedArgs+38 System.Reflection.CustomAttribute.GetCustomAttributesRuntimeModule decoratedModule、Int32 decoratedMetadataToken、Int32 pcaCount、, RuntimeType attributeFilterType,布尔值必须不可编辑,IList 派生属性,布尔值IsDecoratedTargetSecurity透明+571 System.Reflection.CustomAttribute.GetCustomAttributesRuntimeAssembly 程序集,运行时类型caType+103 System.Reflection.RuntimeAssembly.GetCustomAttributesBoolean inherit +37 Owin.Loader.DefaultLoader.SearchForStartupAttributeString friendlyName,IList1错误,布尔值和冲突+294 Owin.Loader.DefaultLoader.GetDefaultConfigurationString friendlyName, IList1错误+105 Owin.Loader.DefaultLoader.LoadImplementationString startupName, IList1 errorDetails+161 Owin.Loader.DefaultLoader.LoadString startupName,IList1错误详细信息+51 Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup+238 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint +103系统。线程。LazyInitializer。确保重新初始化dcoret和target,布尔值和初始化值,对象和同步锁,Func1 valueFactory +115 System.Threading.LazyInitializer.EnsureInitializedT&target、Boolean&initialized、Object&syncLock、Func1 valueFactory+72 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitHttpApplication 上下文+104 System.Web.HttpApplication.registereventsubscriptionswithitintptr appContext、HttpContext、MethodInfo[]处理程序+534 System.Web.HttpApplication.InitSpecialHttpApplication状态, MethodInfo[]处理程序,IntPtr appContext,HttpContext+172 System.Web.HttpApplication Factory.GetSpecialApplicationInstanceIntPtr appContext,HttpContext+352 System.Web.Hosting.PipelineRuntime.InitializeApplicationIntPtr appContext+296

[HttpException 0x80004005:无法加载类型 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider' 从程序集“Microsoft.Practices.EnterpriseLibrary.Common”, 版本=6.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35'] System.Web.HttpRuntime.FirstRequestInitHttpContext上下文+9947380 System.Web.HttpRuntime.EnsureRefirstrequestinitHttpContext上下文 +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivateIIS7WorkerRequest wr,HttpContext+261

如果有人帮忙,那将是一个很大的帮助,我被感动了一个星期

如果需要更多信息,请告诉我

提前感谢。

TL;博士 在web.config/app.config appSettings中配置OWIN启动类,如下所示:

<add key="owin:AppStartup" value="-- your startup class --" />     
<appSettings>  
  <add key="owin:AppStartup" value="-- your startup class --" />       
</appSettings>
如果在web.config中指定启动类,则会阻止应用程序查看并尝试实例化错误的类。因此,要解决此问题,只需在web.config或app.config appSettings中指定应用程序启动类,如下所示:

<add key="owin:AppStartup" value="-- your startup class --" />     
<appSettings>  
  <add key="owin:AppStartup" value="-- your startup class --" />       
</appSettings>
注:

在链接的文档中,您将看到owin:appStartup,但是如果检查源代码,您将看到正确的语法是owin:appStartup,正如上面的代码片段中所使用的那样 您可以用servera的方式指定启动类,但我建议您像下面这样指定它:namespace.ClassName,assemblyName,这是最安全的。
如果您的配置正确,我保证Owin加载程序将接受您真正的启动类,并且不会发生错误。

谢谢,您救了我一天。谢谢,它起了作用,但我必须添加此密钥。更新:如果我们添加两个密钥,解决方案将起作用: