简体   繁体   English

在CRM 2011中升级自定义工作流活动程序集时出错

[英]Error while upgrading a custom workflow activity assembly in CRM 2011

I have a custom workflow activity assembly that is referenced by two workflows. 我有一个由两个工作流引用的自定义工作流活动程序集。 The assembly is currently at version 1.0.builddate.revision. 该程序集目前的版本为1.0.builddate.revision。

I've recompiled an update to the assembly. 我已经重新编译了程序集的更新。 It is now at 1.1.builddate.revision. 现在是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." 但是,当我尝试注册程序集(以编程方式)时,我得到一个FaultException,只是说“无法插入重复键”。

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.xx), 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. 起初我以为我可能正在尝试上传程序集的旧副本(可能还有一个仍然是v1.0.xx),但我可以通过Intellisense检查我实际上是上传了一个比版本更新的程序集版本在我正在尝试注册的组织中。除了AssemblyVersion编号之外,关于自定义活动程序集的所有内容都是相同的。

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. 我不需要知道如何更新工作流以指向新程序集...我只想知道如何成功地将更新的自定义工作流活动程序集上传到CRM。

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. 该codeplex站点上的PluginRegistrationTool是CRM SDK附带的PluginRegistrationTool的修改版本。 This version turns the PluginRegistrationTool into a command line utility that I'm using in our build process. 此版本将PluginRegistrationTool转换为我在构建过程中使用的命令行实用程序。

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. 我已经修改了文件中的Register函数来处理更新与升级方案,方法是将CRM中程序集的AssemblyVersion编号的Major / Minor部分与我尝试上载的程序集的版本号进行比较。 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. 文件中代码的第390行。

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. 需要注意的一件重要事情是,我可以使用SDK中的GUI PluginRegistrationTool执行升级,而不是使用此工具的命令行版本。 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! 在此先感谢您的帮助!

I was creating the new assembly by passing in an the existing assemblies assemblyid. 我通过传入现有的程序集assemblyid来创建新的程序集。 This was causing the duplicate key exception when I called proxy.Create() . 当我调用proxy.Create()时,这会导致重复键异常。 Once I assigned a new Guid to the assemblyid property of the assembly entity, the proxy.Create() function call worked just fine. 一旦我将新的Guid分配给程序集实体的assemblyid属性, proxy.Create()函数调用就可以了。

Thanks for the help on this! 感谢您的帮助!

I've seen this error come up when I forget to sign the assembly with a key. 当我忘记用钥匙签署装配时,我已经看到了这个错误。 Go to project properties and make sure it is signed. 转到项目属性并确保它已签名。 If not, unregister the assembly and then register the signed one, and updates should work from there. 如果没有,取消注册程序集,然后注册已签名的程序集,更新应该在那里工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM