When developing using ASP.net 2.0 (C #) and NHibernate 2.1.0 I get an error message:
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 was selected only on the production server (web hosting company), and everything is in order in my development environment.
I also ran this code below on a production server to see the code security level (CAS), and got True :
System.Security.SecurityManager.IsGranted(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted))
therefore, I can assume that I am currently working in fully trusted mode.
After reading some articles about this problem (not specifically for NHibernate), I realized that I need to add
[assembly: AllowPartiallyTrustedCallers()]
into my AssebmlyInfo.cs file.
:
NHibernate.ByteCode.LinFu.dll AssmeblyInfo.cs? -, web.config ?
,
Tal.