【问题标题】:Error while creating Fluent NHibernate Session factory创建 Fluent NHibernate 会话工厂时出错
【发布时间】:2009-09-24 01:38:50
【问题描述】:

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

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

【问题讨论】:

  • 流畅的 nhibernate 文档:wiki.fluentnhibernate.org/Main_Page
  • 感谢您的帮助,我已经找到了内部异常并将其添加到原始帖子中。不知道下一步该做什么。

标签: nhibernate fluent-nhibernate


【解决方案1】:

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

NHibernate 2 + Fluent Nhibernate medium trust

问题不在于流畅的 NHibernate,而在于 Castle Dynamic Proxy 2。我个人完全信任我部署到的环境,因此我不必解决它。

您的选择是:

  • 获取更新的 Castle Dynamic Proxy 以解决此问题。
  • 尝试其他代理。
  • 使用预生成的休眠代理工厂。

您应该能够在 nhforge.org 上找到所有这些的帖子

【讨论】:

    【解决方案2】:

    查看这个问题的答案:

    assembly does not allow partially trusted callers

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 2019-02-06
      • 2011-12-11
      相关资源
      最近更新 更多