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
HResult=-2146233087
Message=Unable to cast object of type 'Tridion.ContentManager.ContentManagement.Keyword' to type 'Tridion.ContentManager.ContentManagement.VersionedItem'.
Source=mscorlib
StackTrace:
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()
InnerException: