1
votes

I've followed every guide I could find related to ILMerge in order to merge a third party .dll into a custom Dynamics CRM plugin (.dll) so that I may use the functionality.

I am writing a Dynamics CRM plugin that will take a .docx document, populate some information, and add an annotation (Note) to an associated entity. Retrieving the document template and creating an annotation work fine. so, I know my plugin is sound (registers and runs okay).

However, once I attempt to use DocumentFormat.OpenXml to manipulate my document template, I get an error that Dynamics CRM:

Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0......."

After doing some research, I found that I needed to "merge" the DocumentFormat.OpenXml.dll into my plugin .dll.

I installed MSBuild.ILMerge.Task (and ILMerge) in VS2015. During the build process, I now get two messages "Transitive merge" and "Merged assemblies: pathname\my.dll; pathname\DocumentFormat.OpenXml.dll". It seemed to do what I needed. However, when I update the plugin with the new .dll, I get the same "Could not load file or assembly" error message.

I am unable to find any documentation that could further help in ensuring that my referenced DocumentFormat.OpenXml.dll actually gets merged into my target .dll.

1
Instead of updating the existing plugin in PRT, unregister the existing & register the new assembly with merged dllArun Vinoth - MVP
You can use any decompiler to see the content of merged dll & verifyArun Vinoth - MVP
@ArunVinoth, I deleted my .dll and rebuilt it. I used dotPeek to check the .dll to make sure it included the DocumentFormat.OpenXml assembly. I then unregistered and re-registered the .dll in Plugin Registration Tool and it all worked! If you want to post an Answer for unregistering and to re-register the .dll, I'll mark it. Thanks!Rob

1 Answers

1
votes

I am unable to find any documentation that could further help in ensuring that my referenced DocumentFormat.OpenXml.dll actually gets merged into my target .dll.

You can use any decompiler (ex: dotPeek) to see the content of merged dll & verify.

when I update the plugin with the new .dll, I get the same "Could not load file or assembly" error message.

Instead of updating the existing plugin in PRT, unregister the existing & register the new assembly with merged dll.