I have a problem while trying to execute associate method in plugin context
(Post Create and Post Update). The dll is deployed in
database with isolation mode = sandbox.
I have Account and Contact entities with
primarycontactid and contact_customer_accounts relationships. They're all OOTB features. Now, I write a plugin which check if the primarycontactid
field is not full, it will be add to Account's contact_customer_accounts
relationship. Very simple isn't it? But I got this error when execute
Inheritance security rules violated while overriding member:
Security accessibility of the overriding method must match the security accessibility of the method being overriden.
This is my code:
Entity targetEntity = context.InputParameters["Target"] as Entity;
if (targetEntity != null && targetEntity.LogicalName == "account")
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
if (targetEntity["primarycontactid"] != null)
EntityReference contactRef = targetEntity["primarycontactid"] as EntityReference;
if (contactRef != null)
Relationship relationship = new Relationship("contact_customer_accounts");
EntityReferenceCollection relatedEntities = new EntityReferenceCollection();
service.Associate(targetEntity.LogicalName, targetEntity.Id, relationship, relatedEntities);
NOTE: This code works perfectly fine with dll is deployed in database with isolation mode = None.