本文介绍了尽管在完全信任模式下运行,但允许部分受信任的呼叫者安全性异常被抛出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

使用ASP.net 2.0(C#)和NHibernate 2.1.0开发时我收到错误消息:

While developing using ASP.net 2.0 (C#) and NHibernate 2.1.0I am getting the error:

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

仅在生产服务器(网络托管公司)中抛出此错误,并且在我的开发环境中一切正常.

This error is been thrown only in the production server (a web hosting company) and in my development environment everything is fine.

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

I also ran this code below on the production server to see the Code Access Security (CAS) level and got True from:

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

所以我可以假设我当前正在完全信任模式下运行..

so I can assume I am currently running in a full trusted mode..

在阅读了有关此类问题的一些文章之后(并非专门针对NHibernate)我了解我需要添加

After reading some articles about this kind of problem (not specifically for NHibernate)I understood that I need to add

[assembly: AllowPartiallyTrustedCallers()]

到我的AssebmlyInfo.cs文件.

to my AssebmlyInfo.cs file.

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

My question is:Is there a way to solve this exception without having to edit the NHibernate.ByteCode.LinFu.dll's AssmeblyInfo.cs ? Is there something that can be configured in the web.config to allow this kind of action?

谢谢

塔尔.

推荐答案

您是否尝试过此处提到的步骤?

Have you tried the steps called out here?

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

这篇关于尽管在完全信任模式下运行,但允许部分受信任的呼叫者安全性异常被抛出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 18:31