DuplicateRecord Error using Plugin Registration Tool

by Matt 30. July 2010 15:40

A rather annoying error came in the form of 0x80040237 (DuplicateRecord: Operation failed due to a SQL integrity violation) when using the Plugin Registration Tool.  I had written the plugin and put it on the dev server to test it in various scenarios and when I was confident it was bug free, I readied it for deployment to the test server (the final step here before deployment to production server).  I had made several attempts to register the plugin and create the step on dev and on test.  When it was right on dev I exported the xml configuration and imported it to test, but I kept receiving the aforementioned error. 

I'm not sure exactly which step caused it, but somewhere along the lines of my registering/deregistering, creating/removing/altering steps to get this thing set up, a record was made in the database.  Even though I had unregistered both the step and the assembly, the record was still there, so the xml I was trying to import from the other server was attempting to create a record with the same primary key. 

When you unregister a plugin or a step, the database isn't cleansed until the deletion service on the server runs.  Located in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM, it is set to run every 2 hours default.

Rather than wait for the service to run, or to run the service manually, I figured out that in the Plugin Registration Tool there is actually a setting I can use to completely circumvent this issue.  The result is that the record created for the registration is assigned a totally different GUID, and there is no effect on the execution of the plugin or relation to its registered steps.

Categories: CRM