機能ステイプルは常に項目を返していません。別のユーザーによって削除された可能性があります。

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/101155

質問

作成したすべての新しいサイトコレクションにカスタムブランディングをプッシュアウトする機能ステープルドソリューションを作成しようとしています。次のコードは私のイベント受信者にあります:

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        using(SPSite sitecollection = properties.Feature.Parent as SPSite)
        {
            using (SPWeb site = sitecollection.OpenWeb())
            {
                foreach (SPWeb web in sitecollection.AllWebs)
                {
                    try
                    {
                        SPList list = web.Lists.TryGetList("Composed Looks");
                        foreach (SPListItem item in list.Items)
                        {
                            if(item.Title != "Current" || item.Title != "Dynetics")
                            {
                                item.Delete();
                                item.Update();
                            }
                        }
                    }
                    finally
                    {
                        if(web != null)
                        {
                            web.Dispose();
                        }
                    }
                }
            }
        }
    }
.

しかし解決策を展開するとき、エラーが発生します:

Error occurred in deployment step 'Activate Features': Item does not exist. It may have been deleted by another user.
.

なぜ?

役に立ちましたか?

解決

あなたのコードを調べることによって、私は問題は

だと思います
item.Delete();
item.Update();
.

削除した後にアイテムを更新しています削除後にアイテムを更新する必要はありません。

削除されたアイテムを更新することはできません。

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top