2

I am building a site using fluent NHibernate, which works just fine on the dev box. However, after I uploaded it to my host I get the following when trying to run it.

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

Is this something I will need to resolve with the hosting company (CrystalTech)? Any help much appreciated.

The rest of the inner exception:

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 ---

Rex M
  • 142,167
  • 33
  • 283
  • 313
Chin
  • 12,582
  • 38
  • 102
  • 152
  • The problem is not NHibermate but Castle. Check this post: http://blogs.taiga.nl/martijn/2009/06/24/new-adventures-under-medium-trust/ – pedro Nov 10 '09 at 14:38

1 Answers1

3

nHibernate does not work out of the box on a medium-trust environment (which most shared hosts run your application under). Lazy Loading with nHibernate Under Medium Trust describes some of the steps taken to try to get it working.

Rex M
  • 142,167
  • 33
  • 283
  • 313
  • Yikes, I had no problems when I ran a previous NHibernate app using .Net 2,0 on the same hosts. As I opted to use fluent I had to use 3.5 and then the trouble began... thanks for the help. – Chin Sep 24 '09 at 05:16
  • Fortunately, the host has an option to go full trust. Thanks again – Chin Sep 24 '09 at 05:32