This is the error I received when trying to import a managed solution into an organization where an early version of it already existed.
From the import log :
Plugin Types import: FAILURE. Error: Plugin: [PluginAssemblyName], Version=126.96.36.199, Culture=neutral, PublicKeyToken=c66c1d5121b276ee of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: System.Xml.XmlElement caused an exception.
This one was new to me and caused me to have to do some digging, first I had to be reminded how to start digging, and the first step should be to enable tracing, which you can find here : https://support.microsoft.com/en-us/help/907490/how-to-enable-tracing-in-microsoft-dynamics-crm. Then after that do your import and go to the TraceDirectory to find the internal exception causing this import exception.
That lead me to this exception from the trace logs :
>Crm Exception: Message: Plugin Types import: FAILURE. Error: Plugin: [PluginAssemblyName], Version=188.8.131.52, Culture=neutral, PublicKeyToken= of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: System.Xml.XmlElement caused an exception., ErrorCode: -2147188718, InnerException: Microsoft.Crm.CrmException: A managed solution cannot overwrite the PluginType component with Id=098c6ff7-be17-4dee-ae31-5bde6e1d5933 which has an unmanaged base instance.
The last part in bold was the new nugget of information I used to continue with this solution, the problem is the next part is their suggested solution:
The most likely scenario for this error is that an unmanaged solution has installed a new unmanaged PluginType component on the target system, and now a managed solution from the same publisher is trying to install that same PluginType component as managed. This will cause an invalid layering of solutions on the target system and is not allowed.
This organization I’m importing to shouldn’t have an unmanaged component, but apparently it does. I was interesting so I looked up that plugin type in the db for this organization and found it was a plugin type I was not familiar with in and possibly was added by error since instead of a friendly name it had a Guid for a name. The below query helped me find that information.
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) [FriendlyName] FROM [Organization_MSCRM].[dbo].[PluginTypeBase] where PluginTypeId = N’098c6ff7-be17-4dee-ae31-5bde6e1d5933′
After a bit of googling I found this blog post by Donny Riyadi Santoso. Since this above unknown plugin was the issue I decided to open up the plugin registration tool like the blog post suggests and attempt to remove it. The plugin didn’t have any steps and just made me more sure it shouldn’t even be there in the first place.
After unregistering it I was able to successfully import the solution. Even though I only had one problem plugin type, this solution should work if I had to unregister the whole plugin assembly, since the import of the managed solution would replace all the steps I would be removing. Hopefully this helps others!