C# 尽管在完全信任模式下运行,但仍会引发允许部分受信任调用方的安全异常

C# 尽管在完全信任模式下运行,但仍会引发允许部分受信任调用方的安全异常,c#,asp.net,nhibernate,asp.net-2.0,medium-trust,C#,Asp.net,Nhibernate,Asp.net 2.0,Medium Trust,在使用ASP.NET2.0(C#)和NHibernate2.1.0进行开发时 我得到一个错误: System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.LinFu.ProxyFactory' threw an exception. ---> System.Security.SecurityException: That assembly does not allow partiall

在使用ASP.NET2.0(C#)和NHibernate2.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.
此错误仅在生产服务器(一家web托管公司)中抛出,在我的开发环境中一切正常

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

System.Security.SecurityManager.IsGranted(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted))
因此,我可以假设我当前正在完全信任模式下运行

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

[assembly: AllowPartiallyTrustedCallers()]
到我的AssebmlyInfo.cs文件

我的问题是: 有没有一种方法可以解决此异常,而不必编辑NHibernate.ByteCode.LinFu.dll的AssmeblyInfo.cs?是否可以在web.config中配置某些内容以允许此类操作

谢谢


塔尔。

您尝试过这里所说的步骤吗


在我尝试使用NHibernate 2.1.1和LinFu在本地以中等信任运行时,我遇到了同样的问题。我将我的代理切换到Castle,并使用NHibernate代理生成器中的dynamicproxy,我可以在本地运行medium trust。