0
votes

I have a solution with 2 projects

SharePoint.Project

  • WebPart
    • Elements.xml
    • WebPart.webpart

Web.Project

  • WebParts
    • WebPart.cs (NameSpace = Web.Project.WebParts)

SharePoint.Project includes a reference to Web.Project. The SharePoint.Project packages the output from Web.Project and deploys it to the GAC. After the solution is deployed both SharePoint.Project.DLL and Web.Project.DLL exist in the GAC and the web.config of my sharepoint site include a SafeControl that identifies the FullName of the assembly "Web.Project.DLL", the Namespace "Web.Project.WebParts", and the Type "*".

The Problem
Attempt to add the webpart to a page in sharepoint site gives me the error below

A Web Part or Web Form Control on this Page cannot be displayed or imported.
The type could not be found or it is not registered as safe.
2

2 Answers

1
votes

You should check version number and publickeytoken of safe control dll. These property must be similar to dll deployed in GAC.

0
votes

There might be another solution to this problem but what I ended up doing was create a WebPart.cs file in SharePoint.Project and having it derive from the WebPart.cs from Web.Project, and changing the Elements.xml and WebPart.webpart files to reference the WebPart.cs in SharePoint.Project