I am trying to update the value of a keyword by using Core service in SDL Tridion 2013. On saving the item with new value by the following code:

 Client.CheckOut(item.Id, false, new ReadOptions());
 item = Client.Save(item, new ReadOptions());
 Client.CheckIn(item.Id, true, "Scripted Update", new ReadOptions());
 Log.Info($"Successfully updated Item {item.Id}");

I get the following exception. Any idea why this is happening and how can I resolve this?

System.ServiceModel.FaultException`1 was unhandled
  Message=Unable to cast object of type 'Tridion.ContentManager.ContentManagement.Keyword' to type 'Tridion.ContentManager.ContentManagement.VersionedItem'.
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Tridion.ContentManager.CoreService.Client.ICoreService.UndoCheckOut(String id, Boolean permanentLock, ReadOptions readBackOptions)
       at Tridion.ContentManager.CoreService.Client.CoreServiceClient.UndoCheckOut(String id, Boolean permanentLock, ReadOptions readBackOptions)
       at BlackBoard.Tridion.Migration.CoreService.Helpers.CoreServiceHelper.SaveItem(IdentifiableObjectData item) in C:\Code\BBMigrationTool\BlackBoard.Tridion.Migration.CoreService\Helpers\CoreServiceHelper.cs:line 77
       at BBMigrationTool.Actions.MigrateAction.ProcessKeywordMigration(ICoreServiceHelper helper, String language, CategoryKeyword categoryKeyword) in C:\Code\BBMigrationTool\BBMigrationTool\Actions\Migrate.cs:line 58
       at BBMigrationTool.Actions.MigrateAction.Invoke(ICoreService client) in C:\Code\BBMigrationTool\BBMigrationTool\Actions\Migrate.cs:line 35
       at BBMigrationTool.Program.Main(String[] args) in C:\Code\BBMigrationTool\BBMigrationTool\Program.cs:line 77
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

3 Answers 3


Take a look at the class hierarchy in the API doc. Note: Keywords and VersionedItems are both RepositoryLocalObjects, but not all RepositoryLocalObjects are VersionedItems. Take a look in the CM GUI, you'll notice that you don't have versions on Keywords.

So I would suspect that the line where you make the assignment to the 'item' variable is what's causing the problem:

 item = Client.Save(item, new ReadOptions());

My guess is that above the code you showed you declared item as a type which is a VersionedItem (e.g. a Component), Page, Schema, Template), but are now trying to cast it as a Keyword.


As it turned out, Keyword is not versioned. So, the exception is the result of Client.CheckOut(item.Id, false, new ReadOptions()); line. To solve this problem, you just need to separate checkin and checkout commands for items that are not versioned.

  • 1
    You can also use the CoreService Update method. That works for all items: versioned, not versioned, repository-local or system-wide. Nov 3, 2016 at 16:54

The CheckOut (and CheckIn) method signature in CoreService returns a VersionedItemData, as shown below.

VersionedItemData CheckOut(
    string id,
    bool permanentLock,
    ReadOptions readBackOptions

If you try to checkout(or checkin) a Keyword (KeywordData) which does not inherit from VersionedItemData you will get an exception.

Instead just do:

 item = Client.Save(item, new ReadOptions());
 Log.Info($"Successfully updated Item {item.Id}");

More details can be found in the API reference guides here

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.