0

在使用 ASP.net 2.0 (C#) 和 NHibernate 2.1.0 进行开发时,出现错误:

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

此错误在生产服务器(网络托管公司)中引发,在我的开发环境中一切都很好。

我还在生产服务器上运行了下面的代码,以查看代码访问安全 (CAS) 级别并从以下位置获得True

System.Security.SecurityManager.IsGranted(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted))

所以我可以假设我目前正在以完全受信任的模式运行..

在阅读了一些关于这类问题的文章(不是专门针对 NHibernate)后,我明白我需要添加

[assembly: AllowPartiallyTrustedCallers()]

到我的 AssebmlyInfo.cs 文件。

我的问题是:有没有办法解决这个异常而不必编辑NHibernate.ByteCode.LinFu.dll的 AssmeblyInfo.cs ?是否可以在 web.config 中配置一些东西来允许这种操作?

谢谢,

塔尔。

4

1 回答 1

0

你试过这里提到的步骤吗?

在中等信任网络环境中使用 NHibernate

于 2009-12-06T12:05:17.317 回答