创建Fluent NHibernate会话工厂时出错

时间:2009-09-24 01:38:51

标签: nhibernate fluent-nhibernate

有没有人对以下流畅的配置错误有任何经验?

  

faultString =“在创建SessionFactory时使用了无效或不完整的配置。检查PotentialReasons集合,以及InnerException以获取更多详细信息。

我的开发盒没有问题,但是当dll被放到生产服务器上并进行测试时,会发生错误。

开发框指向同一个数据库,因此我认为架构中的差异不是问题。

另外,有没有人知道是否有任何流利的nhibernate文档?

任何指针都非常赞赏。

这是抛出的内部异常:

System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.Castle.ProxyFactory' threw an exception. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.

   at Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly, String strongAssemblyName, String strongModulePath, String weakAssemblyName, String weakModulePath)

   at Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly)

   at Castle.DynamicProxy.ProxyGenerator..ctor()

   at NHibernate.ByteCode.Castle.ProxyFactory..cctor()

The action that failed was:

LinkDemand

The Zone of the assembly that failed was:

MyComputer

   --- End of inner exception stack trace ---

   at NHibernate.ByteCode.Castle.ProxyFactory..ctor()

   at NHibernate.ByteCode.Castle.ProxyFactoryFactory.BuildProxyFactory()

   at NHibernate.Tuple.Entity.PocoEntityTuplizer.BuildProxyFactoryInternal(PersistentClass class, IGetter getter, ISetter setter)

   at NHibernate.Tuple.Entity.PocoEntityTuplizer.BuildProxyFactory(PersistentClass persistentClass, IGetter idGetter, ISetter idSetter)

   at NHibernate.Tuple.Entity.AbstractEntityTuplizer..ctor(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)

   at NHibernate.Tuple.Entity.PocoEntityTuplizer..ctor(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)

   at NHibernate.Tuple.Entity.EntityEntityModeToTuplizerMapping..ctor(PersistentClass mappedEntity, EntityMetamodel em)

   at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory)

   at NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory)

   at NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping)

   at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg)

   at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)

   at NHibernate.Cfg.Configuration.BuildSessionFactory()

   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93"
  message = "faultCode:Server.Processing faultString:'System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.Castle.ProxyFactory' threw an exception. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.

   at Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly, String strongAssemblyName, String strongModulePath, String weakAssemblyName, String weakModulePath)

   at Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly)

   at Castle.DynamicProxy.ProxyGenerator..ctor()

   at NHibernate.ByteCode.Castle.ProxyFactory..cctor()

The action that failed was:

LinkDemand

The Zone of the assembly that failed was:

MyComputer

   --- End of inner exception stack trace ---

   at NHibernate.ByteCode.Castle.ProxyFactory..ctor()

   at NHibernate.ByteCode.Castle.ProxyFactoryFactory.BuildProxyFactory()

   at NHibernate.Tuple.Entity.PocoEntityTuplizer.BuildProxyFactoryInternal(PersistentClass class, IGetter getter, ISetter setter)

   at NHibernate.Tuple.Entity.PocoEntityTuplizer.BuildProxyFactory(PersistentClass persistentClass, IGetter idGetter, ISetter idSetter)

   at NHibernate.Tuple.Entity.AbstractEntityTuplizer..ctor(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)

   at NHibernate.Tuple.Entity.PocoEntityTuplizer..ctor(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)

   at NHibernate.Tuple.Entity.EntityEntityModeToTuplizerMapping..ctor(PersistentClass mappedEntity, EntityMetamodel em)

   at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory)

   at NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory)

   at NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping)

   at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg)

   at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)

   at NHibernate.Cfg.Configuration.BuildSessionFactory()

   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93' faultDetail:'null'"
  name = "Error"
  rootCause = (null)

FluorineStackTrace:

undefined

2 个答案:

答案 0 :(得分:2)

我认为这接近于关于信任的问题:

NHibernate 2 + Fluent Nhibernate medium trust

问题不在于流畅的NHibernate,而是Castle Dynamic Proxy 2.我个人完全信任我部署的环境,所以我没有必要解决它。

您的选择是:

  • 获取更新的城堡动态代理,以便修复此问题。
  • 尝试其他代理。
  • 使用预生成的nhibernate代理工厂。

您应该可以在nhforge.org找到所有这些帖子

答案 1 :(得分:0)

请参阅此问题的答案:

assembly does not allow partially trusted callers

您的开发机器可能完全信任,而您的生产机器可能运行中等信任。