We are using Umbraco 8 and I'm trying to delete an IPublishedContent programatically:
IContent content = _contentService.GetById(contentId);
if (content!=null)
{
_OperationResult opRes = _contentService.Delete(content);
res = opRes.Success;
}
Even if the document gets deleted, the Delete method though throws an exception of type System.Exception {System.InvalidOperationException} with message "Duplicate attribute."
Using _contentService.MoveToRecycleBin(content) works fine!
Though I haven't encountered this exact error, it may be worth investigating if you have any events subscribed to the content deleted event or the content deleting event.
Perhaps one of your subscribers is throwing the exception.
Hi Denis,
Thanks for the answer but no there is no event listner.
I noticed also when I delete en item in the backoffice it works well it sends it to the Recycle bin. But when I try to delete it from the Recycle bin I get the same error
That screenshot suggests that there is something wrong with the uSync content edition ContentSerializerBase class.
Would it be possible for you to update to the latest compatible version of uSync and uSync content edition?
You could also try deleting the uSync folder on your machine and perform a fresh export and try again, perhaps your uSync configurations have gone corrupt somehow.
Delete a content programatically
Hello,
We are using Umbraco 8 and I'm trying to delete an
IPublishedContent
programatically:Even if the document gets deleted, the Delete method though throws an exception of type
System.Exception {System.InvalidOperationException}
with message"Duplicate attribute."
Using
_contentService.MoveToRecycleBin(content)
works fine!Anyone encountered this issue?
Your help is appreciated!
Hi djamel,
Though I haven't encountered this exact error, it may be worth investigating if you have any events subscribed to the content deleted event or the content deleting event. Perhaps one of your subscribers is throwing the exception.
Hi Denis, Thanks for the answer but no there is no event listner.
I noticed also when I delete en item in the backoffice it works well it sends it to the Recycle bin. But when I try to delete it from the Recycle bin I get the same error
Hi djamel,
That screenshot suggests that there is something wrong with the uSync content edition ContentSerializerBase class. Would it be possible for you to update to the latest compatible version of uSync and uSync content edition?
You could also try deleting the uSync folder on your machine and perform a fresh export and try again, perhaps your uSync configurations have gone corrupt somehow.
Hi Denis, Did not try it yet, but will let you know asap. Thank you!
is working on a reply...