简单的自动主题SharePoint应用程序永远不会触发远程事件接收器

时间:2014-01-23 20:39:08

标签: c# .net sharepoint

编辑:我将其更改为SharePoint托管的应用程序,该应用程序仅使用Web部件显示通知。它仍未能成功举办

<AllUsersWebPart WebPartZoneID="full" WebPartOrder="0">
    <![CDATA[ 
  <webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
  <metaData>
  <type
name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,
Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,
PublicKeyToken=71e9bce111e9429c" />
  <importErrorMessage>
  Cannot import this Web Part.
  </importErrorMessage>
  </metaData>
  <data>
    <properties>
      <property name="Title"
       type="string">Announcements</property>
      <property name="ListDisplayName"
       type="string">Announcements</property> 
       <property name="ChromeType"
       type="chrometype">TitleOnly</property>
    </properties>
  </data>
</webPart>

]&GT;

然后我有一个由VS2013生成的/Services/AnnouncementsReceiver.svc,其中包含以下内容:

    public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
    {
        SPRemoteEventResult result = new SPRemoteEventResult();

        switch (properties.EventType)
        {
            // demonstrate ability to modify prior to adding
            case SPRemoteEventType.ItemAdding:
                result.ChangedItemProperties.Add("Body", properties.ItemEventProperties.AfterProperties["Body"] += "\n ** For internal use only ** \n");
                break;

            // demonstrate ability to cancel a delete event
            case SPRemoteEventType.ItemDeleting:
                result.ErrorMessage = "Items cannot be deleted from this list";
                result.Status = SPRemoteEventServiceStatus.CancelWithError;
                break;
        }
        return result;
    }

问题是这段代码永远不会被解雇。我可以创建任意数量的列表项,并且事件永远不会触发。我甚至让它立即抛出异常,并且总是返回错误,但它永远不会触发。它肯定与应用程序的公告列表相关联,它应该捕获正确的事件。这是Elements.xml的片段

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="10000">
    <Receiver>
      <Name>AnnouncementsReceiverItemAdding</Name>
      <Type>ItemAdding</Type>
      <SequenceNumber>10000</SequenceNumber>
      <Url>~remoteAppUrl/Services/AnnouncementsReceiver.svc</Url>
    </Receiver>
    <Receiver>
      <Name>AnnouncementsReceiverItemDeleting</Name>
      <Type>ItemDeleting</Type>
      <SequenceNumber>10000</SequenceNumber>
      <Url>~remoteAppUrl/Services/AnnouncementsReceiver.svc</Url>
    </Receiver>
    <Receiver>
      <Name>AnnouncementsReceiverItemAdded</Name>
      <Type>ItemAdded</Type>
      <SequenceNumber>10000</SequenceNumber>
      <Url>~remoteAppUrl/Services/AnnouncementsReceiver.svc</Url>
    </Receiver>
  </Receivers>
</Elements>

我也确认它正在由Package.package部署。我的智慧结束了。

1 个答案:

答案 0 :(得分:0)

是的,在VS 2013中部署应用非常麻烦,因为缓存一如既往地与现实脱节(缓存我生存的祸根!)。每当事情停止运行时,请尝试以下操作:

  1. 退出VS 2013
  2. 从cmd提示符运行以下命令: 净停止sptimerv4, iisreset / noforce / timeout:300, 净启动sptimerv4
  3. 关闭所有浏览器窗口,启动VS 2013,设置断点,按播放。

根据需要冲洗并重复。