Sometimes when you are deploying plugins you can get into a frustrating error stopping you deploying a plugin/custom workflow. The errors you get don’t really give you can clue as to what the error really is.
In this custom workflow I think I managed to hit most of them.
Firstly, I forgot to sign my custom workflow project (school boy error)
The second error I had was because I had not selected isolation mode, I fixed that by adding this to the RegisterFile.crmregister
So now I was ready, here you can see my trimmed RegisterFile.crmregister. I have temporarily removed all the plugins/custom workflows so I only deploy the new custom workflow (which is quicker).
You can see I have deployed this before because the ID’s are zero’d.
<?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”>
<Solution Assembly=”Plugin.CwaHoskCapacity.dll” Id=”00000000-0000-0000-0000-000000000000″ IsolationMode=”None” SourceType=”Database”>
<WorkflowType FriendlyName=”CwaHoskCapacity” Name=”CwaHoskCapacity” Description=”gets the aviailable appointment between two dates” WorkflowActivityGroupName=”CwaHoskCapacity” Id=”00000000-0000-0000-0000-000000000000″ TypeName=”Plugin.CwaHoskCapacity.CwaGetCapacity” />
I tried to deploy but got this error
Which is below if you can read the picture
Error 17 Error registering plugins and/or workflows. Plug-in assembly does not contain the required types or assembly content cannot be updated. C:\Program Files (x86)\MSBuild\Microsoft\CRM\Microsoft.CrmDeveloperTools.12.targets 176 4 CrmPackage
So what is this error, basically I had already deployed the custom workflow (I didn’t remember) but I didn’t have the guid. So to get round this I unregistered the custom workflow and deleted it.
The Developer Toolkit, great until there’s a problem
I had the pleasure of writing plugins before Microsoft created the CRM Developer toolkit, I remembered at the time trying to persuade people in the office to try it because it made writing and deploying plugins a whole bunch easier.
I have found that 98 percent of the time it works great, but sometimes it can get itself in a mess.
The reason it can be a little temperamental is because it creates all the plugin regisration steps in a the RegisterFile.crmregister and it automatically updates this with your actions in CRM. So if you create a new plugin project, it adds an xml section and then if you add a new plugin or custom workflow, it adds the line into RegisterFile. crmregister.
One of the biggest problems I have with the RegisterFile.crmregister is when the project is in source control and you add a new project but it can’t update the file. Then you have a new project, but no new line in the Register file. crmregister. You don’t really want to manually edit this file because you can get yourself in a real mess. In this scenario the best thing to do is delete the project and then add it again, but after you have made the registerFile. crmregister not read only/ or editable.
For the problem I was experiencing it had created the plugin step but not the actual plugin (e.g. Hosk plugin but no the actual update step). I didn’t know why but I tried deleting the reference for the package and adding a new one but this then brought up errors complaining about a silverlight project, an error I had never seen before.
Plugin Registration and the Developer toolkit – delete do not add
You can delete plugins and plugin steps without too much worry because all the steps to deploy the plugins/custom workflows are in the RegisterFile.crmregister. So the next time you click Deploy – it will deploy the plugin you have deleted (or not in my case)
Adding a plugin using the plugin registration is a bad idea because it won’t automatically be deployed/updated next time you hit the deploy button in Visual studio developer toolkit. You then have to update it manually from now on, which is a pain if all the other plugins are done using the developer toolkit.
I finally admitted defeat and had to delete the project in the developer toolkit and add a new project and add a customer workflow to it and copy my code into the custom workflow.
I am still none the wiser what the error and after spending a couple of hours fiddling and trying things without success I finally had to revert to an old version of the files in source control. I then had to go through the boring process of adding it all back again which only took 30 minutes.
I guess this is one of the disadvantages of relying on the CRM Developer toolkit, all the magic automated code generation can be a mystery when it goes wrong because you aren’t sure what files were changed and with what values, which makes it hard to manually replicate.
It still is a great tool and well done to Microsoft for creating it, it goes wrong so rarely it makes it more frustrating when it happens.
My morning of frustration shows sometimes its quicker to start again than to keep tinkering with a broken CRM Developer Toolkit
The picture was from http://www.pammingle.com