SharePoint EventReceiver Item在自定义列表定义上更新的问题

本文关键字:更新 问题 定义 列表 EventReceiver Item 自定义 SharePoint | 更新日期: 2023-09-27 18:31:33

我的 CustomListDefinition 和 CustomEventReceiver 有问题。

列表定义工作正常。我可以从中创建列表,一切看起来都正常。My EventReceiver 作用于以下四个事件:ItemAdding、ItemAdding、ItemUpdated 和 ItemUpdate。

通过Web界面添加/更新列表项时,一切都可以正常工作,没有任何错误。当我尝试通过 C# (或 PowerShell) 创建或编辑列表项时,出现以下错误:

"未知状态模块:33 消息:134"

即使代码真的什么都不做!我用一个新的空事件接收器重现了这个问题,它附加到我的自定义列表定义的 ItemUpdate 事件。

此问题仅在项目更新事件上发生。当我在没有此事件的情况下部署解决方案时,一切都进展顺利。将 EventReceiver 部署到标准列表(例如 Task ListDefinition)也没有像上面这样的问题。

所以我的结论是,我的ListDefinition中一定有错误。

有人可以帮助我找到错误吗?

我的元素.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List Definition project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="MyProject.ListDefinition.Booking"
        Type="10001"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        AllowDeletion="TRUE"
        DisallowContentTypes="FALSE"
        Sequence="410"
        DisplayName="Anmeldung"
        Description="Anmeldeliste für ein Fest"
        Image="/_layouts/images/itgen.png"/>
</Elements>

我的架构.xml(内容类型和字段定义,如下面的代码中定义)

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Fest Anmeldung" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Fest-MyProject.ListDefinition.Booking" BaseType="0" EnableContentTypes="TRUE" DisableAttachments="TRUE" EnableMinorVersions="FALSE" ModeratedList="FALSE" PrivateList="FALSE" VersioningEnabled="FALSE" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentType ID="0x0100d05f16219b3543eb81f2b7707d50a4d3" Name="externer Teilnehmer" Group="MyProject.Fest" Description="externer Teilnehmer am Fest" Inherits="TRUE" Version="0">
        <FieldRefs>
          <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Titel" Required="FALSE" />
          <FieldRef ID="{F168D67A-8BE4-42ED-B3D6-D04C3CE487F9}" Name="MyProjectFestFirstName" />
          <FieldRef ID="{EA8D4CAA-A219-43ED-8796-345E387BD4C6}" Name="MyProjectFestLastName" />
          <FieldRef ID="{A29AE60F-BCCA-47B5-A498-17B4E7FD4297}" Name="MyProjectFestParticipates" />
          <FieldRef ID="{08885975-334B-4BB6-B7A7-052610C2F885}" Name="MyProjectFestPartner" />
          <FieldRef ID="{5E480332-98F6-4328-955E-037F6F1C66DE}" Name="MyProjectFestChildrenCount0To3" />
          <FieldRef ID="{0BD4A5E1-171F-41AA-9628-979694549807}" Name="MyProjectFestChildrenCount4To8" />
          <FieldRef ID="{90F8CEE7-289B-499B-AA6E-3BE92568948D}" Name="MyProjectFestChildrenCount9To15" />
          <FieldRef ID="{9EB35619-530A-4149-9889-1CEDB7CF3C9F}" Name="MyProjectFestChildrenCount16" />
          <FieldRef ID="{6B63D7A4-4FCC-4C16-979A-BB640FAADA61}" Name="MyProjectFestArrivalDate" />
          <FieldRef ID="{B390E3B7-76C8-4E03-A54E-FD3106689FFE}" Name="MyProjectFestAccommodations" />
          <FieldRef ID="{DEE42C9A-238E-4E93-971B-6BFE3BE5B53B}" Name="MyProjectFestFood" />
          <FieldRef ID="{A6056EA2-E4B8-4555-B5FF-0CDD8FD415FC}" Name="MyProjectFestParticipantCount" />
          <FieldRef ID="{C204C403-CDD5-4A09-AF58-A21D7AEBF985}" Name="MyProjectFestBranch" />
          <FieldRef ID="{EF54ACED-E2BE-4EB7-BF39-1D2A46202DFC}" Name="MyProjectFestDescription" />
        </FieldRefs>
      </ContentType>
      <ContentType ID="0x0100e498ffd129d6485fbe5174d501bbf362" Name="interner Teilnehmer" Group="MyProject.Fest" Description="interner Teilnehmer am Fest" Inherits="TRUE" Version="0">
        <FieldRefs>
          <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Titel" Required="FALSE" />
          <FieldRef ID="{F168D67A-8BE4-42ED-B3D6-D04C3CE487F9}" Name="MyProjectFestFirstName" />
          <FieldRef ID="{EA8D4CAA-A219-43ED-8796-345E387BD4C6}" Name="MyProjectFestLastName" />
          <FieldRef ID="{A29AE60F-BCCA-47B5-A498-17B4E7FD4297}" Name="MyProjectFestParticipates" />
          <FieldRef ID="{08885975-334B-4BB6-B7A7-052610C2F885}" Name="MyProjectFestPartner" />
          <FieldRef ID="{5E480332-98F6-4328-955E-037F6F1C66DE}" Name="MyProjectFestChildrenCount0To3" />
          <FieldRef ID="{0BD4A5E1-171F-41AA-9628-979694549807}" Name="MyProjectFestChildrenCount4To8" />
          <FieldRef ID="{90F8CEE7-289B-499B-AA6E-3BE92568948D}" Name="MyProjectFestChildrenCount9To15" />
          <FieldRef ID="{9EB35619-530A-4149-9889-1CEDB7CF3C9F}" Name="MyProjectFestChildrenCount16" />
          <FieldRef ID="{6B63D7A4-4FCC-4C16-979A-BB640FAADA61}" Name="MyProjectFestArrivalDate" />
          <FieldRef ID="{B390E3B7-76C8-4E03-A54E-FD3106689FFE}" Name="MyProjectFestAccommodations" />
          <FieldRef ID="{DEE42C9A-238E-4E93-971B-6BFE3BE5B53B}" Name="MyProjectFestFood" />
          <FieldRef ID="{A6056EA2-E4B8-4555-B5FF-0CDD8FD415FC}" Name="MyProjectFestParticipantCount" />
          <FieldRef ID="{C204C403-CDD5-4A09-AF58-A21D7AEBF985}" Name="MyProjectFestBranch" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE" />
          <FieldRef ID="{3BAC8D07-9B0D-4D8A-8899-8A398E94A5DC}" Name="MyProjectFestSystemMitaId" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE"  />
          <FieldRef ID="{026BDDB3-C776-4873-A82D-1A87BA4FE4B8}" Name="MyProjectFestSystemAccount" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE"  />
          <FieldRef ID="{99EB27C2-156A-42AD-AC42-8BE91AE1CEC7}" Name="MyProjectFestActivityStatus" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE"  />
        </FieldRefs>
      </ContentType>
    </ContentTypes>
    <Fields>
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Type="Text" DisplayName="Titel" Required="FALSE" />
      <Field
   ID="{F168D67A-8BE4-42ED-B3D6-D04C3CE487F9}"
   Name="MyProjectFestFirstName"
   DisplayName="Vorname"
   Type="Text"
   Required="TRUE"
   Sealed="TRUE"
   AllowDeletion="FALSE"
   Group="MyProjectFest"
   Filterable="TRUE"
   Sortable="TRUE" />
      <Field
        ID="{EA8D4CAA-A219-43ED-8796-345E387BD4C6}"
        Name="MyProjectFestLastName"
        DisplayName="Nachname"
        Type="Text"
        Required="TRUE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE" />
      <Field
        ID="{A29AE60F-BCCA-47B5-A498-17B4E7FD4297}"
        Name="MyProjectFestParticipates"
        DisplayName="Teilnahme am Fest"
        Type="Boolean"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Description="Falls nein, müssen die weiteren Felder nicht ausgefüllt werden!"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{08885975-334B-4BB6-B7A7-052610C2F885}"
        Name="MyProjectFestPartner"
        DisplayName="Teilnahme Partner"
        Type="Boolean"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{5E480332-98F6-4328-955E-037F6F1C66DE}"
        Name="MyProjectFestChildrenCount0To3"
        DisplayName="Anzahl Kinder (0-3)"
        Type="Number"
        Decimals="0"
        Min="0"
        Max="10"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{0BD4A5E1-171F-41AA-9628-979694549807}"
        Name="MyProjectFestChildrenCount4To8"
        DisplayName="Anzahl Kinder (4-8)"
        Type="Number"
        Decimals="0"
        Min="0"
        Max="10"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{90F8CEE7-289B-499B-AA6E-3BE92568948D}"
        Name="MyProjectFestChildrenCount9To15"
        DisplayName="Anzahl Kinder (9-15)"
        Type="Number"
        Decimals="0"
        Min="0"
        Max="10"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{9EB35619-530A-4149-9889-1CEDB7CF3C9F}"
        Name="MyProjectFestChildrenCount16"
        DisplayName="Anzahl Kinder (16+)"
        Type="Number"
        Decimals="0"
        Min="0"
        Max="10"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{6B63D7A4-4FCC-4C16-979A-BB640FAADA61}"
        Name="MyProjectFestArrivalDate"
        DisplayName="Anreise-Datum"
        Type="DateTime"
        Format="DateOnly"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{B390E3B7-76C8-4E03-A54E-FD3106689FFE}"
        Name="MyProjectFestAccommodations"
        DisplayName="Anzahl Übernachtungen"
        Type="Number"
        Decimals="0"
        Min="0"
        Max="10"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field
        ID="{DEE42C9A-238E-4E93-971B-6BFE3BE5B53B}"
        Name="MyProjectFestFood"
        DisplayName="mitgebrachte Speise"
        Type="Text"
        Required="FALSE"
        Sealed="TRUE"
        AllowDeletion="FALSE"
        Group="MyProjectFest"
        Filterable="TRUE"
        Sortable="TRUE"  />
      <Field ID="{3bac8d07-9b0d-4d8a-8899-8a398e94a5dc}" Name="MyProjectFestSystemMitaId" DisplayName="SYSTEM_MITA_ID" Type="Number" Decimals="0" Required="FALSE" Sealed="TRUE" AllowDeletion="FALSE" Group="MyProjectFest" />
      <Field ID="{026bddb3-c776-4873-a82d-1a87ba4fe4b8}" Name="MyProjectFestSystemAccount" DisplayName="Account-Name" Type="Text" MaxLength="5" Required="FALSE" Sealed="TRUE" AllowDeletion="FALSE" Group="MyProjectFest" />
      <Field ID="{99eb27c2-156a-42ad-ac42-8be91ae1cec7}" Name="MyProjectFestActivityStatus" DisplayName="Status" Type="Text" MaxLength="10" Required="FALSE" Sealed="TRUE" AllowDeletion="FALSE" Group="MyProjectFest" />
      <Field ID="{ef54aced-e2be-4eb7-bf39-1d2a46202dfc}" Name="MyProjectFestDescription" DisplayName="Beschreibung" Type="Note" NumLines="3" Required="FALSE" Sealed="TRUE" AllowDeletion="FALSE" Group="MyProjectFest" Filterable="TRUE" Sortable="TRUE" />
      <Field ID="{c204c403-cdd5-4a09-af58-a21d7aebf985}" Name="MyProjectFestBranch" DisplayName="Niederlassung" Type="Choice" Format="Dropdown" BaseType="Text" Required="FALSE" Sealed="FALSE" AllowDeletion="FALSE" Group="MyProjectFest" Filterable="TRUE" Sortable="TRUE">
        <CHOICES>
          <CHOICE>B</CHOICE>
          <CHOICE>E</CHOICE>
          <CHOICE>HH</CHOICE>
          <CHOICE>K</CHOICE>
          <CHOICE>M</CHOICE>
        </CHOICES>
        <Default>K</Default>
      </Field>
      <Field
        ID="{A6056EA2-E4B8-4555-B5FF-0CDD8FD415FC}"
        Name="MyProjectFestParticipantCount"
        DisplayName="Teilnehmeranzahl"
        Type="Calculated"
        ResultType="Number"
        ReadOnly="FALSE"
        Hidden="FALSE"
        Decimals="0"
        Group="MyProjectFest">
        <Formula>=IF([MyProjectFestParticipates]=TRUE,1+IF([MyProjectFestPartner]=TRUE,1,0)+[MyProjectFestChildrenCount0To3]+[MyProjectFestChildrenCount4To8]+[MyProjectFestChildrenCount9To15]+[MyProjectFestChildrenCount16],0)</Formula>
        <FieldRefs>
          <FieldRef Name="MyProjectFestParticipates" />
          <FieldRef Name="MyProjectFestPartner" />
          <FieldRef Name="MyProjectFestChildrenCount0To3" />
          <FieldRef Name="MyProjectFestChildrenCount4To8" />
          <FieldRef Name="MyProjectFestChildrenCount9To15" />
          <FieldRef Name="MyProjectFestChildrenCount16" />
        </FieldRefs>
      </Field>
    </Fields>
    <Views>
      <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="LinkTitleNoMenu">
          </FieldRef>
          <FieldRef Name="MyProjectFestFirstName" />
          <FieldRef Name="MyProjectFestLastName" />
          <FieldRef Name="MyProjectFestParticipates" />
          <FieldRef Name="MyProjectFestParticipantCount" />
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="Modified" Ascending="FALSE">
            </FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
        </ParameterBindings>
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages'viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="Attachments">
          </FieldRef>
          <FieldRef Name="LinkTitle">
          </FieldRef>
          <FieldRef Name="MyProjectFestFirstName" />
          <FieldRef Name="MyProjectFestLastName" />
          <FieldRef Name="MyProjectFestParticipates" />
          <FieldRef Name="MyProjectFestParticipantCount" />
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="ID">
            </FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages'form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages'form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages'form.aspx" WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>

代码有点匿名,因此可能包含一些键入错误。 ;)

希望你能帮我找到我的问题。

编辑:我发现,此错误发生在事件日志中:

加载和运行事件接收器时出错 MyProject.BookingItemEventReceiver in OC.索末节,版本=1.0.0.0, Culture=Neutral,PublicKeyToken=asdasdasd。其他信息是 下面。

事件 ID 为 6875。

SharePoint EventReceiver Item在自定义列表定义上更新的问题

尝试在EventFiringEnabled期间使用set false更新列表项代码。

像这样:

   this.EventFiringEnabled = false;
    //item updated logic
   this.EventFiringEnabled = true;

我有同样的问题,我目前正在尝试解决。就我而言,请使用由网站内容菜单创建的自定义列表。

  1. 但是我检查了在捕获中抛出未经处理的异常时会出现错误。

  2. 另一个原因可能是您在错误消息中重新设置的字符串的长度是 long。

如果我找到一个新的解决方案,我会分享。

问候。。。