C# 注册插件和/或工作流时出错。插件程序集不包含所需类型或程序集内容无法更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9277773/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 06:41:09  来源:igfitidea点击:

Error registering plugins and/or workflows. Plug-in assembly does not contain the required types or assembly content cannot be updated

c#c#-4.0dynamics-crmdynamics-crm-2011

提问by Charan Raju C R

I implemented one custom workflow in in Visual Studio 2010 using CRM 2011 Developer Toolkit. It was working fine with system generated namespace. But, when I changed the namespace of my project, its throwing an error "Error registering plugins and/or workflows. Plug-in assembly does not contain the required types or assembly content cannot be updated."while deploying it. And I have changed the namespace in .crmregister file, project properties and in source code. Then whats the problem here.?

我使用 CRM 2011 Developer Toolkit 在 Visual Studio 2010 中实现了一个自定义工作流。它与系统生成的命名空间一起工作正常。但是,当我更改项目的命名空间时,它抛出错误“注册插件和/或工作流时出错。插件程序集不包含所需的类型或程序集内容无法更新。” 在部署它时。我已经更改了 .crmregister 文件、项目属性和源代码中的命名空间。那么这里有什么问题。?

采纳答案by patricgh

If you are deployong your custome workflows via CRM development toolkint and package and then after that if you have changed any class name or namespace, you must change RegisterFile.crmregister file manually as Visual Studio does not do it for you. So if you change your class name from A to B and your namespace from N to M then 'TypeName' from the below xml in RegisterFile.crmregister file must be as following:

如果您通过 CRM 开发工具包和包部署您的客户工作流,然后如果您更改了任何类名或命名空间,则必须手动更改 RegisterFile.crmregister 文件,因为 Visual Studio 不会为您执行此操作。因此,如果您将类名从 A 更改为 B,将命名空间从 N 更改为 M,那么 RegisterFile.crmregister 文件中以下 xml 中的“TypeName”必须如下所示:

 <?xml version="1.0" encoding="utf-8"?>
<Register xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/crm/2011/tools/pluginregistration">
  <Solutions>
    <Solution Assembly="PackageECRProcesses.CleanRegistration.dll" Id="ab72673b-c0a8-e111-af82-080027dd322f" IsolationMode="None" SourceType="Database">
      <WorkflowTypes>
        <WorkflowType FriendlyName="any" Name="any" Description="any." WorkflowActivityGroupName="account" Id="f0e3f436-c1a8-e111-af82-080027dd322f" TypeName="M.B" />
      </WorkflowTypes>
    </Solution>
  </Solutions>
  <XamlWorkflows />
</Register>

回答by paramosh

Try to change assembly version.

尝试更改程序集版本。

回答by Jason Lattimer

Are you referencing any other assemblies (like Microsoft.Xrm.Sdk)? If so, they need to be merged using a tool like ILMergeif you are deploying to the database. If you are deploying to disk they also need to be present in the assembly folder or installed in the GAC.

您是否引用了任何其他程序集(如 Microsoft.Xrm.Sdk)?如果是这样,如果您要部署到数据库,则需要使用ILMerge 等工具合并它们。如果您要部署到磁盘,它们还需要存在于程序集文件夹中或安装在 GAC 中。

回答by Anwar

Unregister the plugin, then register it again.

取消注册插件,然后重新注册。

回答by Nithin Paul

You may need to check if the plugin with the same name exists as a registered plugin on the organization. Unregister the plugin and register the assembly and steps again.

您可能需要检查与组织中已注册的插件同名的插件是否存在。取消注册插件并重新注册程序集和步骤。

回答by Arthur

If you had some automatically generated classes, e.g. Plugins which you had created via right-click Create Plug-in and then you've deleted it, you have to cleanup it's traces in RegisterFile.crmregister. If it was a plugin, you need to delete a whole branch with it's name.

如果您有一些自动生成的类,例如您通过右键单击“创建插件”创建的插件,然后将其删除,则必须在 RegisterFile.crmregister 中清除它的痕迹。如果它是一个插件,你需要用它的名字删除整个分支。

回答by Alex

I just encountered the exact same issue while toying with the CRM Toolkit.

我刚刚在使用 CRM 工具包时遇到了完全相同的问题。

This is how I solved the issue:

我是这样解决这个问题的:

  1. Go to Settings/Solutions/Yoursolution in CRM
  2. Delete the SDK message processing entries related to the Plugin assembly
  3. Delete the plugin assembly itself from the solution
  4. Go back to Visual Studio and Deploy
  1. 转到 CRM 中的设置/解决方案/您的解决方案
  2. 删除与 Plugin 程序集相关的 SDK 消息处理条目
  3. 从解决方案中删除插件程序集本身
  4. 返回 Visual Studio 并部署

I didn't have to manually edit anything.

我不必手动编辑任何内容。

回答by Phil

This can happen if you change/refactor the main class name of your plugin. (e.g. when the code analysis complains you have a spelling mistake and you fix it) This problem will only show up next time you do the deploy

如果您更改/重构插件的主类名,就会发生这种情况。(例如,当代码分析抱怨您有拼写错误并修复它时)此问题只会在您下次执行部署时出现

So if you've chnaged the name of your plugin class...

因此,如果您更改了插件类的名称...

  1. In the Default CRM Solution delete your plugin from "Plugin-in Assemblies"
  2. Look in the RegisterFile.crmregister file of your plugin. on the XML tag you will see 3 references to your class name - some of these may not have been updated.
  3. update the names in this file and redeploy.
  1. 在默认 CRM 解决方案中,从“插件程序集”中删除您的插件
  2. 查看插件的 RegisterFile.crmregister 文件。在 XML 标签上,您将看到 3 个对您的类名的引用 - 其中一些可能尚未更新。
  3. 更新此文件中的名称并重新部署。

done.

完毕。

(ok just noticed Masoud Ghabachi mentioned this ages ago...)

(好吧,刚刚注意到 Masoud Ghabachi 很久以前就提到过这个……)

回答by M2012

apart of above cases, check .snk file or .pfx file. Does it change in your second deployment.

除上述情况外,请检查 .snk 文件或 .pfx 文件。它是否会在您的第二次部署中发生变化。

in this case try to use old source code or else you need to re register the plug/workflow.

在这种情况下,请尝试使用旧的源代码,否则您需要重新注册插件/工作流。

回答by Scorpion

Make sure that your plugin/workflow class is a public class.

确保您的插件/工作流类是公共类。

I got the same error because my plugin class was private.

我遇到了同样的错误,因为我的插件类是私有的。