How do I change my library to allow partially trusted callers?
I get the following error:
Server Error in '/' Application.
Security Exception
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: That assembly does not allow partially trusted callers.
Source Error: [No relevant source lines]
Source File: App_Web_kzj7vfkn.2.cs
Line: 0
After some more looking at the problem it seems like it's System.Web.UI.ClientScriptManager that causes the problem
Definition. Allows an assembly to be called by partially trusted code. Without this declaration, only fully trusted callers are able to use the assembly.
A partial-trust assembly means that the code runs at less than full trust. The . NET Framework has several predefined trust levels that you can use directly or customise to meet your specific security requirements.
Assuming you have access to the sources of your library.
A pretty good and detailed explanation is given here Also read the links at the bottom to get a better understanding.
There is a possibility that not your assembly is the problem but you are calling another assembly that does not allow partially trusted callers. At runtime you can use fuslogvw to find which assembly is giving you the problems. If this is the problem and you have the sources of this assembly you need to also apply the [assembly:AllowPartiallyTrustedCallers] attribute to that assembly, if you don't have the sources the only option I know of is to replace the troublesome library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With