nhibernate 在 trust level = medium 的时候是死是活

photoplan 2009-08-28 10:03:36
最新版的nhibernate是2.1, 最近感兴趣, 热情高涨地学习一通, 然后突发奇想把 trust level 改成 medium, 结果是这著名的玩意立刻挂掉了. Security Exception 跳出来说, 不好意思, 您不能运行. 网上搜, 说是把nhibernate 的 lazy loading, 还有什么 proxy 的, 总之很高级的玩意, 禁用就行了. 照着做, 结果还是一样, 不能运行. 在这问题上耗了几天, 没有解决掉, 热情迅速降温到冰点以下. 同时为 nhibernate 感叹, 这么一个好东西, 随便一个 medium trust level 就给宰了, 是不是冤了点儿?

各位可有什么好办法?
...全文
77 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
photoplan 2009-08-30
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 mythad 的回复:]
This is what I did to the configuration

Apply the requirepermission="false" in the web.config section of nHibernate
Set the hibernate.use_reflection_optimizer in the web.config to false
Set the hibernate.bytecode.provider in the web.config to null.
This is what I did in the mapping files

Set the lazy attribute of all classes to "false"
Set the lazy attribute of all collections to "false"
Remove the proxy attribute of all classes

看看这个行么?

[/Quote]

不行,可能是我没配置明白,有直接可用的例子吗
mythad 2009-08-30
  • 打赏
  • 举报
回复
This is what I did to the configuration

Apply the requirepermission="false" in the web.config section of nHibernate
Set the hibernate.use_reflection_optimizer in the web.config to false
Set the hibernate.bytecode.provider in the web.config to null.
This is what I did in the mapping files

Set the lazy attribute of all classes to "false"
Set the lazy attribute of all collections to "false"
Remove the proxy attribute of all classes

看看这个行么?
photoplan 2009-08-30
  • 打赏
  • 举报
回复
我正在试 SubSonic, 看这个如何
photoplan 2009-08-30
  • 打赏
  • 举报
回复
我的问题似乎是出在这个文件上, Iesi.Collections.dll, 我挨个试过 bin 里的东西, 把这个文件删掉, 会提示加载程序集失败, 把它放上, 就抛 SecurityException:

异常详细信息: System.Security.SecurityException: 请求“System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”类型的权限已失败。

堆栈跟踪很短:

[SecurityException: 请求“System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”类型的权限已失败。]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +99



photoplan 2009-08-30
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 cuike519 的回复:]
http://codebetter.com/blogs/peter.van.ooijen/archive/2008/05/09/nhibernate-and-medium-trust.aspx
[/Quote]

cuike519 大哥, 这文章你看全文了吗, 我怎么看着好像他也没成功, E文不行看错了别笑话.
cuike519 2009-08-30
  • 打赏
  • 举报
回复
http://codebetter.com/blogs/peter.van.ooijen/archive/2008/05/09/nhibernate-and-medium-trust.aspx
wuyq11 2009-08-29
  • 打赏
  • 举报
回复
wuyq11 2009-08-29
  • 打赏
  • 举报
回复
因为在Medium信任的情况下
Reflection,Emit(包括DynamicMethod),CodeDom,都会受到很多限制.
在Medium信任的情况下, NHibernate读写数据的性能就更加比不上CSPAbstractRecord了.
mythad 2009-08-29
  • 打赏
  • 举报
回复
那你就别用这个trust level了,换低一点能运行么?nh也就是个持久层的框架,用的多了就会发现它缺点也很多的。
photoplan 2009-08-29
  • 打赏
  • 举报
回复
感谢两位,

高手们帮下忙
threenewbee 2009-08-29
  • 打赏
  • 举报
回复
同情lz,我以前用 NHBN也很不爽,问题多多。

为啥不用 ADO.NET 实体框架,我觉得这个很牛的。
photoplan 2009-08-28
  • 打赏
  • 举报
回复
顶一下

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧