Security Exception in SharePoint Visual WebPart

When I tried to add a custom Data Calendar Control in SharePoint WebPart, But unfortunately I got an error

DLL referenced file not had Strong Key

that inform me the DataCalender.dll is not signing with a strong key.Thence,

  • I followed the mention steps in this hint, to sign DataCalender.dll with a strong key that had been signed properly.
  • I copied the DataCalender.dll to
    • C:\inetpub\wwwroot\wss\VirtualDirectories[port]_app_bin folder of SharePoint Web Application.
  • I opened Visual Studio > Open SharePoint Solution > Solution Explorer > Add reference for DataCalender.dll that located in Bin folder of SharePoint Web Application.
  • I deployed the SharePoint Solution that has been deployed successfully.

But unfortunately When I tried to add the Visual WebPart to a SharePoint Page I got the following error :

Security Exception


Cause :

The SharePoint does not have the trust level to run this Visual WebPart .

Solution :

To solve this issue,you should follow the mentioned steps below one by one :

  • Install DataCalender.dll (your dll file) with strong key to GAC. It will then get full trust.
  • Go into the web.config of SharePoint site and add it to the trusted list.
  • Make sure that the dll file is exist in
    • C:\inetpub\wwwroot\wss\VirtualDirectories[port]_app_bin folder. This is set in the global SharePoint config to fully trust any assemblies in there.
  • Temporary Change the Trust tag in web config <trust level=”WSS_Minimal” originUrl=”” /> to <trust level=”Full” originUrl=”” />.
  • Deploy the Visual WebPart then rollback the Trust tag in web config from <trust level=”Full” originUrl=”” /> to <trust level=”WSS_Minimal” originUrl=”” />.

Enjoy 🙂

For more details about Data Calendar check this

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s