[Dyn 365] Could not load file or assembly ‘file:///C:\Program Files\Dynamics 365\server\bin\assembly\****.dll’ or one of its dependencies. Access is denied.

I’ve setup clean on premise installation of Dynamics 365 v9.0. When I tried to create new workflow I got this error:

Could not load file or assembly ‘file:///C:\Program Files\Dynamics 365\server\bin\assembly\Microsoft.Dynamics.Service.Plugins.dll’ or one of its dependencies. Access is denied.

Issue was that folder was not inheriting security permissions from C:\Program Files\Dynamics 365\Server\bin. Right click on assembly folder -> Properties -> Security tab  -> Advanced -> Click on Enable inheritance button.
After that I needed to restart IIS. Works fine then!


[CRM] How to publish entity using SDK?

If we did some changes on Account entity using SDK, we can very simply publish them. There is PublishXmlRequest message provided by SDK.

// Publish Account entity
string accountEntityXml = "Account";

PublishXmlRequest publishxmlrequest = new PublishXmlRequest
ParameterXml = String.Format(accountEntityXml)


We can use ParameterXml to define which solution component to publish in the request.

If we want to publish all customization we will use PublishAllXmlRequest.

PublishAllXmlRequest publishAllReq = new PublishAllXmlRequest();

[CRM] Render email template – InstantiateTemplateRequest

I wanted to have step in workflow process where draft Email will be created using template.

There are two out of the box options regarding Email step in workflow. We can create draft email with specified body and subject. Other option is to send email using some workflow.

In order to create draft email with rendered template I created custom workflow activity which will execute InstantiateTemplateRequest, and for a result return rendered subject and message body.

This is a part of workflow activity:

InstantiateTemplateRequest instTemplateReq = new InstantiateTemplateRequest
    TemplateId = templateId,
    ObjectId = contactId,
    ObjectType = "contact"
InstantiateTemplateResponse instTemplateResp = (InstantiateTemplateResponse)service.Execute(instTemplateReq);

Three parameters are sent, Template Id (Guid of email template), Contact Id as Object Id and contact Object Type. Here is rendered template of Contact type.

After executing request we need to pull out result details from InstantiateTemplateResponse object:

Entity template = instTemplateResp.EntityCollection.Entities[0];
 if (template != null && template.Attributes.Contains("description"))
    TemplateSubject.Set(executionContext, template.Attributes["subject"].ToString());
    TemplateDescription.Set(executionContext, template.Attributes["description"].ToString());

In last workflow step I added Create new email step where Subject and Description are applied on new email record.

[CRM] Activity Party Types

I was looking for Email senders/receivers in [ActivityPartyBase] table. To identify what Email entity field is related to some ActivityParty we are using column [ParticipationTypeMask] in table [ActivityPartyBase]. Here are possible values for this column:

Activity party type Value Description
Sender 1 Specifies the sender.
ToRecipient 2 Specifies the recipient in the To field.
CCRecipient 3 Specifies the recipient in the Cc field.
BccRecipient 4 Specifies the recipient in the Bcc field.
RequiredAttendee 5 Specifies a required attendee.
OptionalAttendee 6 Specifies an optional attendee.
Organizer 7 Specifies the activity organizer.
Regarding 8 Specifies the regarding item.
Owner 9 Specifies the activity owner.
Resource 10 Specifies a resource.
Customer 11 Specifies a customer.
Partner 12 Specifies a partner.

[CRM] Default entities and status codes

Status and Status reason are both optionsets.  Option set have an int value and a text value.  The text value is meta data and the int value is held in the database on the database field.

Default entities have two status values


  • Active = 0
  • Inactive = 1

Status reason have different default values

Status Reason

  • Active = 1
  • Inactive = 2


Taken from Hosk’s blog

[CRM Email Router] Incoming Status: Failure – The account does not have permission to impersonate the requested user.

This errors occurred when I configured incoming email profile in Email router 2015. To resolve this I had to configure exchange impersonation in Exchange 2013 for email router account.

Exchange Impersonation enables a caller to impersonate a given user account. This enables the caller to perform operations by using the permissions that are associated with the impersonated account, instead of the permissions that are associated with the caller’s account.

This is command that should be executed within Exchange power shell console:

New-ManagementRoleAssignment -Name:”CRM mail account” -Role:ApplicationImpersonation -User:emailrouter

MSDN link

[CRM, Email router] System.UnauthorizedAccessException: Access to the path ‘C:\Program Files\Microsoft CRM Email\Service\Microsoft.Crm.Tools.EmailAgent.xml’ is denied.

After fresh installation of CRM email router 2015 (07.00.0000.3543) I setup all necessary configuration. It is connected to CRM organization but I got following error:

#16192 – The Email Router service could not run the service main background thread. The Email Router service cannot continue and will now shut down. System.Configuration.ConfigurationErrorsException: System information was not specified in the Email Router service configuration file. The Email Router service cannot continue and will now shut down. —> System.UnauthorizedAccessException: Access to the path ‘C:\Program Files\Microsoft CRM Email\Service\Microsoft.Crm.Tools.EmailAgent.xml’ is denied.

After short investigation I figured out that email router service and CRM installations have different version. Actually CRM has already upgraded to version 07.0.0002.0053 (0.2 Update installed). So solution was to upgrade email router to the same version. Everything works OK then 🙂