Wednesday, February 5, 2014

Error: Unable to load plug-in Assembly in offline mode for Dynamics CRM 2011 / CRM 2013

Hi Guys,

If you are working on Dynamics CRM 2011 or 2013, and you need to work with offline mode of CRM Outlook Client. And when you do something that need a custom plugin execution. You may come face-to-face with this kind of probleme :

Error Message : Unable to load plug-in Assembly


 And when you download the log file you will see something like this :

Public key token 0868a8a927707e20 is not found in allow list.


The reason for this error is that when you install the CRM Outlook offline client, this one adds in your system registry a new entry called Allow List that contains all public token keys of the allowed plugins. But, this Allow List don't contain the public token key of your plugin. You need to add all public token keys of the offline plugins in this Allow List.

To do it you need to :

  • Open your PRT (Plugin Registration Tool).
  • Select, one by one, all plugins that contain offline mode. Properties window will contains all details about your plugin
  • Copy the public key token like this.


  • You need to open your system registry
  • Navigate to this location : HKEY_CURRENT_USER\Software\Microsoft\MSCRMClient\AllowList

  • Click on AllowList and create a new key:

  • Paste the public token key in the name of the new key.
  • Repeat this operation for all offline plugins

Have a nice day,

N.JL

Tuesday, February 4, 2014

How to programmatically initilize mapped attributes when you create a new record

Hi Guys,

When you have a 1:N relationship in Dynamics CRM 2011/2013 between two entities such as Account and Contact, this relationship can be respresented by a subgrid of contacts on the account form.

If this relationship contains some mapping attributes, and you want to create a contact from this subgrid, the new contact record will contains all mapped attributes with data from the parent account record. but when you want to create this record programmatically using a plugin, this mapping will dont work.

To force this mapping using the code, you need to use InitializeFromRequest - InitializeFromResponse.

The InitializeFromRequest - InitializeFromResponse message allow CRM to initialize all mapping attribute between source and target entities.

the InitializeFromResponse object contain a member called Entity that contains a memory image of the target entity record with all mapped attributes. So you need to get this Entity object and call service.create().

There is an example that illustrate this case :

  // Allow CRM to initialize all mapping attributes between account and contact entities.
  InitializeFromRequest initializeFromRequest = new InitializeFromRequest();
  initializeFromRequest.EntityMoniker = new EntityReference("account", accountRecord.Id);
  initializeFromRequest.TargetEntityName = "contact";
  initializeFromRequest.TargetFieldType = TargetFieldType.All;

  InitializeFromResponse initializeFromResponse = (InitializeFromResponse)service.Execute(initializeFromRequest);


  // Create a new contact record with all initialized mapped attributes
  Entity contact = initializeFromResponse.Entity;
  service.Create(contact);



have a nice day.

N.JL