简体   繁体   中英

SharePoint WebPart

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.

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

可能有另一个解决方案,但我最终要做的是在SharePoint.Project中创建一个WebPart.cs文件,并使其从WebPart.csWebPart.cs派生 ,并更改Elements.xmlWebPart.webpart文件在SharePoint.Project中引用WebPart.cs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM