Thursday 18 July 2024

Use External DLL's in MS CRM Online Plugin

 

Use External DLL's in MS CRM Online Plugin


Hi folks, In this blog i will demonstrate how to use External dll in CRM Online Plugin.

At first let me tell about storage options available in Microsoft Dynamics CRM (Online or On-Premise)

MS CRM Online: If you want to register plugin assembly in Dynamics CRM Online that is Sandbox mode(Partial Trust). You will have only one option available i.e "Database". You can't use other options available for storing assemblies.

Advantage: If you have Multiple Dynamics CRM environment then registering plugins in database is the best option as you can include it in solution and easily migrate from one instance to other.

Dis-Advantage: If you register plugins in Database you can't include external dll.

 

MS CRM On-Premise: If you are using Dynamics CRM on-premise instance then you will have other options to store assemblies like GAC or Disk.

GAC: If u register plugin in GAC, external dll can be included and also versioning is used, By using GAC Versioning we can avoid conflict of multiple assemblies.

Disk: You can use external dll. It will be stored in CRM Server bin folder. Debugging is easy if we use disk for storing plugins.

Now let us dig into the concept of merging dll's with an scenario.

Suppose you are using Dynamics CRM Online instance and you want to send data from CRM Online plugin to Third Party Web API, To achieve this you will be using some external dlls to serialize or deserialize the data.

For merging external dll, we can use "ILMerge".

ILMerge is used to merge multiple .Net assemblies into single assembly.

Step 1: Install ILMerge dll from the Nuget solution manager.

 Install-Package MSBuild.ILMerge.Task
Step 2: Right Click on the external assemblies you have to merge.
  • Click Properties
  • Set Copy Local to True.
  • Finally Rebuild the solution.
  • By Default below assemblies will be set to true.

    • Microsoft.Xrm.Sdk.dll
    • Microsoft.Crm.Sdk.Proxy.dll
    • Microsoft.IdentityModel.dll

 

 

Register the updated assembly. It will work as charm.

Hope it's Helpful. Happy Coding

No comments:

Post a Comment

Power Apps Drag & Drop Kanban code sample

  Introduction: The Kanban Board App Developers at a software company use the Kanban board to show their progress on development tasks and b...