views:

239

answers:

1

Hey,

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.

A: 

Have you tried the steps called out here?

Using NHibernate in a Medium Trust web environment

Michael Maddox