views:

2023

answers:

2

Hi, I wonder if any one has had any experience of the following fluent config error.

faultString = "An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

I have no problems on my development box but when the dlls are put up on the production server and tested the error occurs.

The development box is pointing at the same database so I don't think differences in schema are the issue.

Also, does any one know if there is any documentation for fluent nhibernate?

Any pointers much appreciated.

Here is the inner exception thrown.

"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

A: 

See the answer to this question:

http://stackoverflow.com/questions/1469820/assembly-does-not-allow-partially-trusted-callers

Your development machine is likely running full trust, while your production machine is likely running medium trust.

Michael Maddox
+1  A: 

I think this is close to this question about trust:

http://stackoverflow.com/questions/710903/nhibernate-2-fluent-nhibernate-medium-trust

The issue isn't about fluent NHibernate, but Castle Dynamic Proxy 2. I personally have full trust on the environments I deploy to so I haven't had to resolve it.

Your options are to:

  • Get an updated Castle Dynamic Proxy so that this is fixed.
  • Try another proxy.
  • Use the pregenerated nhibernate proxy factory.

You should be able to find posts for all of these on nhforge.org

Min