NHibernate Forge
The official new home for the NHibernate for .NET community
Wikis » How to » Run in Medium Trust » Revision #3

Run in Medium Trust: Revision #3

Wiki Page Hierarchy

Pages

Page Details

First published by:
Bill Pierce
on 09-22-2008
Last revision by:
John Davidson
on 07-08-2011
3 people found this article useful.

Run in Medium Trust

Using NHibernate in a Medium Trust web environment requires the following:

  • All referenced assembiles must be marked with AllowPartiallyTrustedCallers
  • Web.config configSections must be marked with requirePermission="false"
    <configSections>
     
    <section name="hibernate-configuration" requirePermission="false" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
     
    <section name="log4net" requirePermission="false" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
     
    ...
    </configSections>
  • Reflection optimization must be disabled
    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <reflection-optimizer use="false" />
       ...
    </hibernate-configuration>
  • Default lazy loading must be disabled on all class mappings
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Example.Domain" namespace="Example.Domain.Models" default-lazy="false">
      <class name="Person">
        ...
      </class>
    </hibernate-mapping>
    Alternativly you could pre-generate lazy loading proxies using NHibernate ProxyGeneators.
Powered by Community Server (Commercial Edition), by Telligent Systems