Saturday, January 31, 2009

The assembly does not allow partially trusted callers

I was creating a Custom page (code in separate code behind file) for sharepoint. I had to deploy both the .aspx file and .dll file. I deployed the .aspx file and the web.config in a separate folder under layouts folder. The .dll file was deployed to the bin folder of the web application. But while trying to see the page, it was showing the following error message.

"The assembly does not allow partially trusted callers"

After some investigation i found that the error will be happening when we try to call some trusted assemblies from not trusted or partially trusted assemblies.
I was able to resolve the problem by doing the following steps.

  1. Signing the assembly with "Mark assemblies with AllowPartiallyTrustedCallerAttribute(APTCA)" option checked in website project properties-->MSBuild Options
  2. Deployed the dll in to the GAC
  3. Added the assembly in the safe control list of the web.config of SharePoint site.

No comments: