IIS7 + NHibernate:对已标记为删除的注册表项尝试非法操作

时间:2009-12-03 17:55:10

标签: nhibernate iis-7

我们有一个asp.net MVC应用程序,使用Fluent Nhibernate在IIS7及其上运行Windows Sever 2008.经常(虽然到目前为止我们还没有一贯地重现它)在构建之后我们得到一个黄色的死亡屏幕,但有这个例外:

[COMException (0x800703fa): Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA)]
   System.Reflection.Assembly._nDefineDynamicModule(Assembly containingAssembly, Boolean emitSymbolInfo, String filename, StackCrawlMark& stackMark) +0
   System.Reflection.Emit.AssemblyBuilder.DefineDynamicModuleInternalNoLock(String name, Boolean emitSymbolInfo, StackCrawlMark& stackMark) +381
   System.Reflection.Emit.AssemblyBuilder.DefineDynamicModuleInternal(String name, Boolean emitSymbolInfo, StackCrawlMark& stackMark) +105
   System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule(String name, Boolean emitSymbolInfo) +83
   Castle.DynamicProxy.ModuleScope.CreateModule(Boolean signStrongName) +206
   Castle.DynamicProxy.ModuleScope.ObtainDynamicModuleWithWeakName() +63
   Castle.DynamicProxy.Generators.Emitters.ClassEmitter.CreateTypeBuilder(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, TypeAttributes flags, Boolean forceUnsigned) +78
   Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, TypeAttributes flags, Boolean forceUnsigned) +69
   Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope modulescope, String name, Type baseType, Type[] interfaces) +36
   Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildClassEmitter(String typeName, Type parentType, Type[] interfaces) +140
   Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(Type[] interfaces, ProxyGenerationOptions options) +648
   Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors) +139
   Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, IInterceptor[] interceptors) +39
   NHibernate.ByteCode.Castle.ProxyFactory.GetProxy(Object id, ISessionImplementor session) +416

[HibernateException: Creating a proxy instance failed]
   NHibernate.ByteCode.Castle.ProxyFactory.GetProxy(Object id, ISessionImplementor session) +642
   NHibernate.Tuple.Entity.AbstractEntityTuplizer.CreateProxy(Object id, ISessionImplementor session) +49
   NHibernate.Persister.Entity.AbstractEntityPersister.CreateProxy(Object id, ISessionImplementor session) +102
   NHibernate.Event.Default.DefaultLoadEventListener.CreateProxyIfNecessary(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options, IPersistenceContext persistenceContext) +255
   NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +400
   NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) +923
   NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) +169
   NHibernate.Impl.SessionImpl.InternalLoad(String entityName, Object id, Boolean eager, Boolean isNullable) +310
   NHibernate.Type.EntityType.ResolveIdentifier(Object id, ISessionImplementor session) +211
   NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity, Boolean readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent, PostLoadEvent postLoadEvent) +527
   NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList hydratedObjects, Object resultSetId, ISessionImplementor session, Boolean readOnly) +544
   NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +1158
   NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +105
   NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister) +472
   NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId) +77
   NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session) +30
   NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session) +182
   NHibernate.Event.Default.DefaultLoadEventListener.LoadFromDatasource(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +174
   NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +194
   NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) +923
   NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) +169
   NHibernate.Impl.SessionImpl.Get(String entityName, Object id) +191
   NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id) +139
   NHibernate.Impl.SessionImpl.Get(Object id) +136
   Huddle.DataAccess.Persistence.Repository`1.FindById(Int32 id) +281
   Huddle.WebSite.Global.GetWorkspace() +241
   Huddle.WebSite.Global.Application_BeginRequest(Object sender, EventArgs e) +437
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

似乎其他一些people发现了同样的问题,虽然没有人似乎有解决方案,但有什么想法?

2 个答案:

答案 0 :(得分:8)

这听起来就像我在Windows 2008上看到的COM +和MSMQ一样。当用户注销时,无论是否有任何剩余的打开句柄,Windows 2008都会卸载用户注册表配置单元。您应该在事件日志中看到正在使用它的进程卸载配置单元的条目。

可以设置一个GPO来防止这种情况发生(DisableForceUnload)

此处提供更多信息:

http://blogs.msdn.com/distributedservices/archive/2009/11/06/a-com-server-application-may-stop-working-on-windows-server-2008.aspx

答案 1 :(得分:3)

这看起来像是.NET框架本身的一个错误。

请注意,innermost method being called未指定它可以抛出一个ComException。

我建议更新到Castle Dynamic Proxy(2.2 beta)的最新版本,看看问题是否仍然存在。

如果是,您可以尝试使用其他代理提供商之一。

并将此问题报告给Microsoft Connect