Custom Web Parts and Local Deployments
by liquidpooled on Apr.23, 2008, under Microsoft, Office, Sharepoint Server, Visual Studio 2005
When trying to deploy your web parts the “right” way (local content deployment, bin directory, etc.) one issue that can crop up deals with the actual compilation of your custom web part.
If you receive the following error message:
Unable to add selected web part(s).
<Web Part Name>: Assemblies that implement ASP.NET Web Parts and are installed into a partially trusted location, such as the bin directory, must be compiled with the AllowPartiallyTrustedCallersAttribute set for import to succeed.
then you need to add a line to your AssemblyInfo.cs such as the following:
[assembly: System.Security.AllowPartiallyTrustedCallers()]
A good primer on the attribute can be found here.