我现有的 Web 部件无法在 SharePoint 中工作

发布于 2024-07-27 13:29:50 字数 1175 浏览 5 评论 0原文

我有一个标准的 ASP.NET 2.0 网站。
它有一个网页。
我的 Company.Web.dll 中有一个 Web 部件,它显示在我网站上的 Web 部件页面上。
一切都很好!!!

我想在 SharePoint 2007 中使用相同的 Web 部件。

我在 VS2008 中有一个使用 SharePoint 1.2 扩展的“站点定义”项目。 我尝试了各种方法将外部程序集中的 Web 部件添加到我的站点定义中。 我已经能够部署 Web 部件(将其添加到 Web 部件页面的 Web 部件列表中),但我未能成功将其添加到页面。

我光荣的失败:

  1. 创建了一个 shell Web 部件来仅显示现有的 Web 部件,基本上只是使用我的部件作为控件。
  2. 创建新的Web部件时尝试修改VS2008创建的X.webpart和X.xml文件。

将 Web 部件添加到页面时,两者都会导致以下错误:

异常 Microsoft.SharePoint.WebPartPages.WebPartPageUserException: 无法导入 XXXX Web 部件。
在 Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean 清除连接)位于 Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager 经理、XmlReader 读取器、布尔值 清除连接,Uri webPartPageUri, SPWeb spWeb)位于 Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager 经理、XmlReader 读取器、布尔值 清除连接,SPWeb spWeb)位于 Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String 事件参数)

是否需要通过特殊方式将现有 Web 部件添加到站点定义中?

I have a standard ASP.NET 2.0 website.
It has a webpage page.
I have a webpart in my Company.Web.dll that I display on my webpart page on my website.
All is good!!!

I would like to use this same webpart in SharePoint 2007.

I have a "site definition" project in VS2008 using Extensions for SharePoint 1.2. I have tried various ways to add the webpart from an outside assembly to my site definition. I have been able to deploy the webpart (where it is added to the webpart list of a webpart page) but I have been unsuccessful at adding the it to a page.

My Glorious Failures:

  1. Created a shell webpart to just display the existing web part, basically just using my part as a control.
  2. Attempted to modify the X.webpart and X.xml files created by VS2008 when you create a new webpart.

Both result in the following error while adding the web part to the page:

Exception
Microsoft.SharePoint.WebPartPages.WebPartPageUserException:
Cannot import XXXX Web Part.
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)

Is there a special way I need to add my existing webpart to my site definition?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

比忠 2024-08-03 13:29:51

这听起来像是在部署时解决 GUID 的问题,因为您可以在此 SO 中阅读 问题

This sounds like a problem resolving the GUID at deployment time, as you can read about in this SO question.

怪我太投入 2024-08-03 13:29:51

要查找 Web 部件无法导入的详细信息,请检查 ULS 日志。 它们通常位于 %CommonProgramFiles%\Microsoft Shared\web server extensions\12\LOGS。 当您尝试将 Web 部件添加到页面时,将在此处记录一个条目。 这应该会给你更多的细节。

我的猜测是这是一个代码访问安全问题。 您的 Web 部件必须经过强签名,并且需要 SharePoint Web 应用程序的 web.config 中的 SafeControl 条目。 除了这些之外,您应该能够将其添加到全局程序集缓存中以测试它是否有效(最佳实践是编写 CAS 策略文件)。 有关详细信息,请参阅在 Windows SharePoint Services 中部署 Web 部件

在尝试将其集成为站点定义的一部分之前,我会尝试这些步骤。 那么至少您知道 Web 部件将实际运行。

此外,VSeWSS 确实是为从一开始就使用它来开发 Web 部件而设计的。 如果您有原始源,则可以尝试使用 VSeWSS 创建新的 Web 部件,然后替换为自定义代码并更新 .webpart 和功能 XML 文件。 那么它的表现应该会好一点。 如果您尚未承诺使用 VSeWSS,请尝试 WSPBuilder,因为它不会那么痛苦。

To find the details of why the web part won't import, check the ULS logs. These are typically located at %CommonProgramFiles%\Microsoft Shared\web server extensions\12\LOGS. An entry will be logged here at the time you attempt to add the web part to the page. This should give you more detail.

My guess is that it is a code access security issue. Your web part must be strongly signed and needs a SafeControl entry in the web.config of the SharePoint web application. Apart from these things you should be able to just add it to the Global Assembly Cache to test if it works (best practice is to write a CAS policy file). See Deploying Web Parts in Windows SharePoint Services for more details.

I would try these steps before trying to integrate it as part of a site definition. Then at least you know the web part will actually run.

Also, VSeWSS is really designed for developing your web part using it from the very start. If you have the original source, you could try creating a new web part with VSeWSS and then replace with your custom code and update the .webpart and feature XML files. Then it should behave a little better. If you haven't committed to VSeWSS, try WSPBuilder as it's less painful.

我恋#小黄人 2024-08-03 13:29:51

ASP.NET Web 部件和 Sharepoint Web 部件相同。 您应该能够在 Sharepoint 中使用 ASPNET Web 部件。 请参见下表:

ASP.NET 2.0 Web 部件

  • 适合大多数业务需求。
  • 将 Web 部件分发到运行 ASP.NET 2.0 的网站或 SharePoint 网站。
  • 当您想要在 SharePoint 网站上重用为 ASP.NET 2.0 网站创建的一个或多个 Web 部件时。
  • 使用 Windows SharePoint Services 3.0 提供的数据或功能。 例如,您正在创建一个可处理网站或列表数据的 Web 部件。

基于 SharePoint 的 Web 部件

  • 当您想要使用基于 SharePoint 的 Web 部件基础结构将一组 Web 部件迁移到 Windows SharePoint Services 3.0 时。
  • 创建跨页面连接。
  • 在 Web 部件区域之外的 Web 部件之间创建连接。
  • 使用客户端连接(Web 部件页面服务组件)。
  • 使用允许缓存内容数据库的数据缓存基础设施。

要使 Sharepoint Web 部件在标准 ASPNET 应用程序中工作,您需要在 Visual Studio 中重新创建 Web 部件(作为 ASPNET Web 部件),而无需 Sharepoint 2007 引用才能使其正常工作。

我过去使用过的一个漂亮工具是 SmartPart 值得一试:

这可以让你创建一个Visual Studio 中的 ASP.NET 用户控件(可视化),然后将其托管在 Sharepoint 中。 smartpart 充当用户控件的包装器 wepart。 可以将其视为 Sharepoint 中的页面查看器 Web 部件,只不过它不是 HTML 页面,而是 ASP.NET 用户控件。

ASP.NET webparts and Sharepoint Webparts are NOT the same. You should be able to use a ASPNET webpart within Sharepoint. See the following table:

ASP.NET 2.0 Web Part

  • For most business needs.
  • To distribute your Web Part to sites that run ASP.NET 2.0 or SharePoint sites.
  • When you want to reuse one or more Web Parts created for ASP.NET 2.0 sites on SharePoint sites.
  • To use data or functionality provided by Windows SharePoint Services 3.0. For example, you are creating a a Web Part that works with site or list data.

SharePoint-based Web Part

  • When you want to migrate a set of Web Parts using the SharePoint-based Web Part infrastructure to Windows SharePoint Services 3.0.
  • To create cross page connections.
  • To create connections between Web Parts that are outside of a Web Part zone.
  • To work with client-side connections (Web Part Page Services Component).
  • To use a data-caching infrastructure that allows caching to the content database.

For a Sharepoint webpart to work in a standard ASPNET application you would need to recreate your webparts in Visual Studio (as an ASPNET webpart) without the Sharepoint 2007 references for it to work correctly.

One nifty tool which I have used in the past is the SmartPart Worth checking out:

This lets you create a ASP.NET usercontrol (visually) in Visual Studio and then host this in Sharepoint. The smartpart acts as a wrapper wepart for your user control. Think of it like the page viewer webpart in Sharepoint except instead of it being HTML pages its ASP.NET UserControls.

長街聽風 2024-08-03 13:29:51

您需要 WSS 3.0、SharePoint MOSS 或 2007 才能使用 ASP.NET 2.0 WebPart。 SharePoint 2003 或更低版本以及 WSS 2.0 或更低版本不支持 ASP.NET WebPart。

You would need WSS 3.0, SharePoint MOSS or 2007 to use ASP.NET 2.0 WebParts. SharePoint 2003 or below and WSS 2.0 or below do not support ASP.NET WebParts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文