0

I have a custom made Web Part that I want to add to a page in my SharePoint site. But I'm having this error message every time:

A Web Part or Web Form Control on this Page cannot be displayed or imported. The type SharePointProject1.WebPartName.WebPartName, SharePointProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=32e59cf2728706a0 could not be found or it is not registered as safe.

I have activated the solution feature at the site collection level. I have also ensured that the safe control entries are enabled. as well as editing the xml file to set SafeControl entry to true. Then I removed and uninstalled the solution and installed it again. But still same error message. So what am I missing here?

2

What it could be:

  1. Your Web part is not correctly declared as Safe in the web.config. Do you see the web.config SafeControl entry in the wb.config? Was is added automatically? Can you share it with us so we can check together?
  2. The class SharePointProject1.WebPartName.WebPartName is not declared public.
  3. The DLL is not in the GAC neither in the app_bin folder. How do you deploy the solution?
  • I have checked in web.config, I couldn't find the control there. Do I add it manually or it should be added??? – Khalifa Sabt Feb 29 '16 at 7:22
  • the class is public and for no.3 how do I confirm this? you mean the dll of the solution file? – Khalifa Sabt Feb 29 '16 at 7:23
  • The SafeControl entry should be in the web.config file of the SharePoint Web application (e.g. C:\inetpub\wwwroot\wss\VirtualDirectories\80). If it's not, maybe you did not deploy correctly the WSP package, or maybe not against the correct Web application. How did you deploy the WSP? – Evariste Feb 29 '16 at 8:32
  • As for your second question: yup, I mean the DLL from the solution; should be deployed into the GAC when you deploy the WSP file. – Evariste Feb 29 '16 at 8:33
  • ya you were right, it was an issue with the wsp deployment. now it's working. I have uninstalled and removed wsp package, deleted existing webparts from the gallery then reinstalled it again on the web app. it is working now. thanks!! – Khalifa Sabt Feb 29 '16 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.