c# - SharePoint 错误 : "Cannot import Web Part"

标签 c# sharepoint moss web-parts project-server

我有一个自己开发的 Web 部件,如果我手动安装该 Web 部件就没问题。

但是,当我按照本网站上的说明打包 Web 部件时: http://www.theartofsharepoint.com/2007/05/how-to-build-solution-pack-wsp.html

我在日志文件中收到此错误:

09/23/2008 14:13:03.67  w3wp.exe (0x1B5C)                           0x1534  Windows SharePoint Services     Web Parts                       8l4d    Monitorable Error importing WebPart. Cannot import Project Filter.   
09/23/2008 14:13:03.67  w3wp.exe (0x1B5C)                           0x1534  Windows SharePoint Services     Web Parts                       89ku    High        Failed to add webpart http%253A%252F%252Fuk64p12%252FPWA%252F%255Fcatalogs%252Fwp%252FProjectFilter%252Ewebpart;Project%2520Filter.  Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Cannot import Project Filter.     at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean clearConnections)     at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, Uri webPartPageUri, SPWeb spWeb)     at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, SPWeb spWeb)     at Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(...  
09/23/2008 14:13:03.67* w3wp.exe (0x1B5C)                           0x1534  Windows SharePoint Services     Web Parts                       89ku    High        ...String eventArgument)     

相关的一点是:

http%253A%252F%252Fuk64p12%252FPWA%252F%255Fcatalogs%252Fwp%252FProjectFilter%252Ewebpart;Project%2520Filter.
Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Cannot import Project Filter.
at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean clearConnections)
at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, Uri webPartPageUri, SPWeb spWeb)
at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, SPWeb spWeb)
at Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

伴随着一条相当简洁的错误消息:“无法导入 Web 部件”。

我已经检查并且我的 .dll 已注册为安全的,它在 GAC 中,该功能已激活,并且 Web 部件出现在 Web 部件库中,所有正确的属性表明 Web 部件文件已成功读取.

一切似乎都已就绪,但我从 SharePoint 那里收到了错误,而且几乎没有解释如何解决它。

感谢任何寻找解决方案的帮助。

最佳答案

想通了。

错误消息来自 .webpart 文件:

<?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <!--
      The following Guid is used as a reference to the web part class, 
      and it will be automatically replaced with actual type name at deployment time.
      -->
      <type name="7F8C4D34-6311-4f22-87B4-A221FA8735BA" />
      <importErrorMessage>Cannot import Project Filter.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">Project Filter</property>
        <property name="Description" type="string">Provides a list of Projects that can be used to Filter other Web Parts.</property>
      </properties>
    </data>
  </webPart>
</webParts>

问题是原始 .webpart 文件是在安装了 Visual Studio Extensions for WSS 的 32 位系统上创建的。

但是,由于我现在使用的是 64 位计算机,VSEWSS 不可用,而且我认为这会导致上述 GUID 未被替换,因为我没有使用这些部署工具。

用完整的类型名称替换 GUID 是可行的。

因此,如果您遇到来自 importErrorMessage 节点的错误消息,请检查 .webpart 文件中的类型节点是否更像这样(不相关的示例):

<type name="TitleWP.TitleWP, TitleWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" />

格式如下: 类、命名空间、版本、文化、公钥

您可以从与您的 SharePoint 实例关联的 web.config 文件中轻松获取它,因为它将位于安全控件列表中。

关于c# - SharePoint 错误 : "Cannot import Web Part",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/120928/

相关文章:

javascript - 内容编辑器模式弹出窗口中的自定义 SharePoint 2013 列表/表单仅在表单所在的列表中打开...不在弹出窗口中

"Stop Inheriting Permissions"功能的 SharePoint 2013 事件接收器

Sharepoint 博客文章 : Sort based on Published date

c# - 从 C# 中的 Filter Graph Manager 获取接口(interface)

c# - 如何将 "BDC Wildcard Filter"添加到 ReadList 方法

C# 代码生成器/格式化程序

sharepoint - 将InfoPath表单部署到不同的SharePoint服务器

html - SandcaSTLe ->输出到HTML->导入到MOSS实用程序

c# - 哪种算法更适合在数据库中隐藏重要字符串? (该字符串不是密码)

c# - asp.net c# 公共(public)统计和并发用户