• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
tonycol
博客园    首页    新随笔    联系   管理     

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" default-lazy="false" assembly="Example.Domain" namespace="Example.Domain.Models">
      
    <class name="Person">
        
    ...
      
    </class>
    </
    hibernate-mapping>
    Alternativly you could keep lazy loading enabled (the default) and Pre-Generate Lazy Loading Proxies

 

Using ActiveRecord 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="activerecord" requirePermission="false" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"/>
      
    <section name="log4net" requirePermission="false" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
      
    ...
    </configSections>
  • Reflection optimization must be disabled
    Place this line after your call to ActiveRecordStarter.Initialize(...): 
    NHibernate.Cfg.Environment.UseReflectionOptimizer = false; 

  • Default lazy loading must be disabled on all class mappings
    <activerecord isWeb="true" default-lazy="false">
      
    <config>
        
    ...
      
    </config>
    </
    activerecord>
    Alternativly you could keep lazy loading enabled (the default) and Pre-Generate Lazy Loading Proxies
posted @ 2010-12-02 00:06  tonycol  阅读(263)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3