“CallList:无法导入此 Web 部件”安装 SharePoint Web 部件时

发布于 2024-08-25 03:32:01 字数 363 浏览 4 评论 0原文

我创建了一个 Web 部件。当我将 WebPart 添加到页面时,出现以下错误。 Error MEssage

如果我删除 WebPart 构造函数中的内容,它将添加到页面中。然后,如果我在页面上部署代码并将 WebPart 全部准备好,WebPart 将正确显示。我无法将其添加到之前收到错误的其他页面。

所以我推测构造函数有问题。破坏它的行是

var site = new SPSite("http://website/site");

This 已通过注释代码找到。安装WebPart时不能创建SPSite吗?

I have created a WebPart. When I add the WebPart to a page I get the error below.
Error MEssage

If I delete what is in my constructor for my WebPart it will then add to the page. Then if I deploy my code with the WebPart all ready on a page the WebPart will display correctly. I can't add it to other pages I get the error before.

So I presume that there is a problem with the constructor. The line that is breaking it is

var site = new SPSite("http://website/site");

This has been found by commenting code out. Can you not create an SPSite when installing a WebPart?

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

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

发布评论

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

评论(2

呆萌少年 2024-09-01 03:32:01

您是否将构造函数代码封装在 try/catch 块中?它可能会由于某种原因引发异常。

否则,请尝试将构造函数代码移至 OnInit 以查看是否会产生影响。

Do you have your constructor code wrapped in a try/catch block? It may be throwing an exception for some reason.

Otherwise, try moving your constructor code to OnInit to see if that makes a difference.

感情废物 2024-09-01 03:32:01

是的,我们可以使用 spsite 对象。

您可以更改您的代码吗,例如

 SPSite site = new SPSite("http://website/site");

让我知道它是否有效。

yes we can use spsite object.

Can you change your code like

 SPSite site = new SPSite("http://website/site");

let me know if it works.

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