Error registering plugins and/or workflows. Plug-i

2019-02-16 18:31发布

问题:

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.?

回答1:

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:

 <?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>


回答2:

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

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

I didn't have to manually edit anything.



回答3:

In our case we used ILMerge and accidentally we merged Microsoft.Xrm.Sdk.dll into our plugin, removing this dll (copy local = false) fixed the issue.

This merged dll was not working anyway as it throw security exception Inheritance security rules violated while overriding member: 'Microsoft.IdentityModel.Claims.ClaimsIdentity.System.Runtime.Serialization.ISerializeable.GetObjectData this GetObjectData was present in Microsoft.Xrm.Sdk.dll hence security exception from SandBox deployment.



回答4:

Try to change assembly version.



回答5:

Are you referencing any other assemblies (like Microsoft.Xrm.Sdk)? If so, they need to be merged using a tool like ILMerge if 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.



回答6:

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.



回答7:

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.



回答8:

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.

done.

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



回答9:

Unregister the plugin, then register it again.



回答10:

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

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



回答11:

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

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



回答12:

Check RegisterFile.crmregister workflow property TypeName must not contain any spaces.



回答13:

I changed the signing key file and got the error, changing it back to the previous key file solved the issue for me.



回答14:

Your version needs to be the same one as the one that has been published already for an Upgrade. We had an Assembly version of 1 major, 0 minor - and the one we tried to publish was 12 major, 0 minor.

We changed the Visual Studio solution number back to version 1.0.0.0, Build, Load Assembly, Update - and it worked!

Deleting it would NOT solve the issue due to the dependencies from Workflows if they were used.

We switched Tracing On and found the SQL script to find the culprit.



回答15:

I've gotten this when the preImage element was placed after the postImage element in the register. Swapping their places fixed it.