I have a custom workflow activity assembly that is referenced by two workflows. The assembly is currently at version 1.0.builddate.revision.
I've recompiled an update to the assembly. It is now at 1.1.builddate.revision.
Based on information I found here I believe that since I'm changing the minor number in the assembly version, that would need to perform an upgrade (not an update) of the custom workflow activity.
My understanding of an upgrade is essentially that I should just register a new assembly and then point the process workflows at the new revision of the custom activities.
However, when I attempt to register the assembly (programmatically), I get a FaultException stating nothing more than "Cannot insert duplicate key."
System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> was caught
Message=Cannot insert duplicate key.
Source=mscorlib
Action=http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/CreateOrganizationServiceFaultFault
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 Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Create(Entity entity)
at PluginRegistrationTool.XrmService.Create(Entity entity) in C:\Workspaces\xxxxxx\Lib\PluginRegistrationTool\PluginRegistrationTool\XrmService.cs:line 390
InnerException:
I can only guess at what key this fault refers to. At first I thought that maybe I was trying to upload an old copy of the assembly (potentially one that was still v1.0.x.x), but I can check via Intellisense that I am in fact uploading a newer version of the assembly than exists in the org I'm attempting to register in. Everything about the custom activity assembly is the same except for the AssemblyVersion number.
What am I not getting about this process? I don't need to know how to update the workflow to point to the new assembly... I just want to know how to upload an updated custom workflow activity assembly to CRM successfully.
The code that is attempting to upgrade the custom workflow activity assembly is a slightly modified version of this. The PluginRegistrationTool on that codeplex site is a modified version of the PluginRegistrationTool that comes with the CRM SDK. This version turns the PluginRegistrationTool into a command line utility that I'm using in our build process.
I've modified the Register function in this file to handle the update vs upgrade scenarios by comparing the Major/Minor portion of the AssemblyVersion number of the assembly in CRM with the version number of the assembly I'm attempting to upload. I can see that it is attempting an upgrade (creating a new assembly), but then I get the exception I mentioned earlier on the
organizationServiceProxy.Create(entity);
or line 390 of the code in this file.
One important thing to note is that I can perform the upgrade using the GUI PluginRegistrationTool from the SDK, just not with this commandline version of the tool. Also, I get the same error message if I try to import a managed solution with an "upgraded" version of the custom workflow activity assembly on top of a managed solution with an older version of the assembly.
Thanks in advance for your help!