Sharepoint:从项目事件处理程序创建子网站
我有一个“项目列表”(标题、领导、成员、站点 URL),它应该引用具有项目列表的站点下的团队站点。因此,我在沙盒解决方案中的功能中添加了一个 SPItemEventReceiver
来实现此目的。
在 ItemAdding(properties)
中,我调用以下代码:
string projectName = properties.AfterProperties["Title"].ToString();
SPWeb currentWeb = properties.Web;
SPWeb subweb = currentWeb.Webs.Add(projectName, projectName,
"Project site for " + projectName, (uint) currentWeb.Locale.LCID,
Microsoft.SharePoint.SPWebTemplate.WebTemplateSTS, true, false);
但是在调试时,对 Add 的调用会抛出 SPException
,其中包装了 FAILED HResult 代码的 COMException,并带有消息 沙盒代码执行请求被拒绝,因为沙盒代码主机服务太忙,无法处理该请求。
参数是否有问题,或者我应该将实际创建委托给工作流?
I have a "project list" (title, lead, members, site-URL) that is supposed to refer to team sites under the site that has the project list. So I added an SPItemEventReceiver
to my feature in a sandbox solution to do that.
In ItemAdding(properties)
, I invoke the following:
string projectName = properties.AfterProperties["Title"].ToString();
SPWeb currentWeb = properties.Web;
SPWeb subweb = currentWeb.Webs.Add(projectName, projectName,
"Project site for " + projectName, (uint) currentWeb.Locale.LCID,
Microsoft.SharePoint.SPWebTemplate.WebTemplateSTS, true, false);
But when debugging, the call to Add throws an SPException
wrapping a COMException for a HResult code of FAILED with the message The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request.
Is there something wrong with the parameters, or should I delegate the actual creation to a workflow instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面尝试一下:
公共覆盖无效 ItemAdding(SPItemEventProperties 属性)
{
base.ItemAdding(属性);
Following try with this:
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
似乎出现了一些僵局的情况;我通过使用事件后 ItemAdded 解决了我的特殊情况(从 AfterProperties 中的设置值更改为更新 ListItem)。出于某种原因,对 Webs.Add() 的调用正常完成......
Seems to be some deadlock situation; I solved my particular case by using the post-event ItemAdded instead (changing from setting values in AfterProperties to updating the ListItem instead). There, for some reason, the call to Webs.Add() completes normally...