Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly does not allow partially trusted caller

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

Edit

After some more looking at the problem it seems like it's System.Web.UI.ClientScriptManager that causes the problem

like image 868
Andreas Avatar asked Aug 15 '10 10:08

Andreas


People also ask

What is the purpose of allow partially trusted callers attribute?

Definition. Allows an assembly to be called by partially trusted code. Without this declaration, only fully trusted callers are able to use the assembly.

What is partially trusted code?

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.


1 Answers

Assuming you have access to the sources of your library.

  • Give the library you are trying to call a strong name.
  • Add [assembly:AllowPartiallyTrustedCallers] to the library that you are trying to call.
  • Create a code group to set permissions to the 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.

like image 163
KeesDijk Avatar answered Sep 25 '22 00:09

KeesDijk