Allowing partially trusted callers security exception is been thrown althought running on Full trust mode

為{幸葍}努か 提交于 2019-12-25 16:08:43

问题


While developing using ASP.net 2.0 (C#) and NHibernate 2.1.0 I 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.

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..

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

[assembly: AllowPartiallyTrustedCallers()]

to my AssebmlyInfo.cs file.

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?

Thanks,

Tal.


回答1:


Have you tried the steps called out here?

Using NHibernate in a Medium Trust web environment



来源:https://stackoverflow.com/questions/1848342/allowing-partially-trusted-callers-security-exception-is-been-thrown-althought-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!