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
_tcmPreviewand 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.