We are working to migrate our SDL8.5 code of EventHandler to SDL9.5. We updated our libraries and the .Net framework to v4.8 and adapted our code to deploy it using the Add ons of Type


AddOns is deployed correctly but when we try to publish an item it gives us an error when trying to initialise a class

var pubTarget = new PublicationTarget(new TcmUri(_tcmPreview), item.Session);

The error we get is,

Unexpected item type: TargetType. Component: Tridion.ContentManager.CoreService Errorcode: 805 User: NT AUTHORITY\NETWORK SERVICE StackTrace Information Details: at Tridion.ContentManager.IdentifiableObject.AssertValidId(Boolean allowUriNull) at Tridion.ContentManager.SystemWideObject..ctor(TcmUri id, Session session) at Com...EventHandler.PublishItem(RepositoryLocalObject item, PublishEventArgs args)

Has anyone else faced similar issue during the migration of SDL8.5 to SDL9.5

  • What is the value of _tcmPreview and where do you get it from? Looking at the error it seems it is the TCM URI of a Target Type instead of a Publication Target. Oct 14, 2021 at 15:33

1 Answer 1


The solution to our problem was to change the

var pubTarget = new PublicationTarget(new TcmUri(_tcmPreview), item.Session);


var pubTarget = new TargetType(new TcmUri(_tcmPreview), item.Session)

Seems that in the version 9.5 PublicationTarget is not needed anymore

  • Thanks for asking and sharing. Indeed, Publication Targets have been removed from the API and configuration as part of changes for Topology Manager. By Tridion Sites 9.5, they're mentioned in the deprecated features, though I thought they were completely gone. :-) Oct 1, 2021 at 13:16
  • Well, Publication Targets still exist as a deprecated feature. If you have existing Publication Targets in your system, everything (including your original code) should still work. Oct 14, 2021 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.