In Dynamics 365 Online and all versions of Dynamic CRM, using external dll in plugin is not supported.
When you use external dll in your plugin, an error will be displayed by your plugin.
In this blog we will describe the steps needed to build your plugin and use the external dlls.
Add your external dll to the solution, like we add DocumentFormat.OpenXml
Right click on your external dll, click on properties and set the Copy Local property to True.
And other dll you are using in your solution like
Be sure to change these dll properties and set Copy Local to False. If you do not change these settings, ILMerge will include them in your assembly and it will most likely crash your CRM environment.
Please make sure you set Copy Local to true for external dll only.
Install MSBuild.ILMerge.Task into your solution through Nuget.
Build you solution: when you build your solution, please note it will take more time than your normal solution building because it must merge external dll with your plugin dll.
Register the plugin in CRM and enjoy the external dll.
That’s it for today, I hope it will help!