views:

212

answers:

1

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

A: 

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.

KeesDijk
I have the source, but I have trouble creating a key pair, since I'm using the express versions and don't have access to the vs command prompt.
Andreas
I am not entirely sure and don't have an express version at hand but I believe the express editions have a signing tab (project properties) that you can use to create a strong named assembly
KeesDijk