{Tips & Tricks} Explore a managed solution’s plugin assembly programmatically in Dynamics CRM Online.

I never find a good title to explain my blog post. So I would rather suggest you read through my entire post even if blog title seems absolutely non-sense Smile.

So coming back to the topic here, first let me tell you why I needed to do all this stuff. My customer environment contained a managed solution which had a utility plugin. The solution was developed by some consultant company who was working for my customer initially. The source code for the managed solution was with the consultant firm. Unfortunately during handover, the source code handover got missed.

My client is running CRM 2015 online and all of a sudden, this managed assembly started throwing error. It contained some cool stuffs. So we cannot get rid of it. After multiple discussions with our client, we decided to rewrite the stuffs in the assembly. So we need the assembly. But how do we do it?

Since it is a managed solution, you cannot export it. After putting my head around it, I created a console application to get out the DLL. Just a few lines of code and I am pretty sure that if you are from a programming background like me, you would love this. So let’s see the code here.

private static void ReadPluginAssembly(OrganizationServiceProxy proxy)
            var queryExp = new QueryExpression("pluginassembly");
            queryExp.Criteria.AddCondition("name", ConditionOperator.Like, "TestPlugins%");

            var result = proxy.RetrieveMultiple(queryExp);

            var base64Content = result.Entities[0].GetAttributeValue<string>("content");
            var byteContent = Convert.FromBase64String(base64Content);

            System.IO.File.WriteAllBytes(@"c:\debajit\TestPlugins.dll", byteContent);


Let me explain the code here a bit. First I have queried the pluginassembly entity for the particular assembly in question here and retrieve the content field. The content field is where CRM stores the entire content of the plugin assembly as base 64 encoded string.

So I get the content and covert the base64 string to byte content. And then I saved the byte content to an assembly with the same name.

And how do I get the code from here. Use the wonderful Red-Gate .NET reflector or ILSpy and you would find much of the code. With little bit of modifications, you can just copy paste the entire code.

Hope you find this interesting.

7 thoughts on “{Tips & Tricks} Explore a managed solution’s plugin assembly programmatically in Dynamics CRM Online.”

    1. Hi Rahul,
      Even if you include a managed component in unmanaged solution, when you export the solution, the item will not available in the exported solution. Managed components are referred in the solution just as reference.


  1. Hi , I appreciate your deep thinking and effort it works. But check the syntax

    var byteContent = Convert.FromBase64String(base64Content);
    System.IO.File.WriteAllBytes(@”c:\abhi\new.dll”, byteContent);

    1. Thanks for reading my blog. Could you let me know what is wrong here. Sorry but I am not able to find out. my be i am overlooking
      something here

  2. System.IO.File.WriteAllBytes(@”c:\debajit\TestPlugins.dllteContent);- this doesn’t work.

    this worked – System.IO.File.WriteAllBytes(@”c:\abhi\new.dll”, byteContent);

    1. ot sure from where in the blog you are getting this line.

      System.IO.File.WriteAllBytes(@”c:\debajit\TestPlugins.dllteContent); It has no commas and .dlltecontent I am sure is typo and is not what you meant to write

      Below is the screenshot of the blog code referring to the same line


      I am pretty sure you are not referring to the path here. That is the path of my machine. If there is anything else, I would correct

      1. i am referring to path in my machine, and it’s working correctly. Thanks for great in depth information. It’s only minor typo error. That already you have rectified above.

Leave a Reply