I’ve deployed to a server a web application that uses NHibernate. The application compiles and runs fine on my local dev machine, but there’s an issue with NHibernate on the new server. I get the following error:
Description: The application attempted
to perform an operation not allowed by
the security policy. To grant this
application the required permission
please contact your system
administrator or change the
application’s trust level in the
configuration file.Exception Details:
System.Security.SecurityException:
Request for the permission of type
‘System.Configuration.ConfigurationPermission,
System.Configuration, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=tokenkeyhere’
failed.
It suggests to change the application’s “trust level” in the configuration file. How exactly do I do that? This is the first time I’ve deployed a NHibernate web app, so I’m at a loss.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
We’ve been looking at this a lot lately. Here is a link on running NHibernate in medium trust
This is the most succinct explanation I’ve seen of the different trust levels: Trust Levels Demystified
From the article:
- Full trust – your code can do anything that the account running it can do. - High trust – same as above except your code cannot call into unmanaged code. i.e. Win32 APIs, COM interop. - Medium trust – same as above except your code cannot see any part of the file system except its application directory. - Low trust – same as above except your code cannot make any out-of-process calls. i.e. calls to a database, network, etc. - Minimal trust – code is restricted from anything but the most trival processing (calculating algorithms).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0