Setting the trust level for newly installed Web Parts

Problem description: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=1

After installing a new SharePoint Web Part, it is not working and you get an error like Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

Solutions:
1. Change the trust level for your SharePoint Web Part
This means the trust level of your newly installed SharePoint Web Part is not set correctly. To fix this, follow these steps:
Start the Visual Studio Command Prompt (in the program group Visual Studio Tools).Go to the directory where the dll is installed (typically c:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin).Run the command gacutil /i newwebpartdll.dll. Run iisreset.
Your newly installed SharePoint Web Part will be added to the global assembly cache (GAC) and everything should work fine now.
2. You can also increase the trust level of the SharePoint Site. Furthremore, you can also deploy a CAS (code access security file) and explicitly say which permissions your web parts can access (i.e. HD, registry).
Deploying to the GAC is the best practice, but it will not work in the most secure SharePoint admin setups. Putting your assemblies inside the GAC will allow them to do anything in code and not all admins will allow that.

Comments

Popular posts from this blog

Understanding Top line and Bottom line?

How to activate PF UAN account

Scrum Master vs Product Owner