
Hey yall I have this plugin to prevent the user from creating contact dupes but when i try to register the assembly using the dll I get this error could you guys help I am not sure what this error means
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
namespace DuplicateDetection
{
public class DetectDuplicates : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IOrganizationServiceFactory servicefactory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service =
servicefactory.CreateOrganizationService(context.UserId);
#region working code
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName != "contact")
{
return;
}
if (context.Depth > 1)
{
return;
}
try
{
if (entity.Attributes.Contains("emailaddress1"))
{
string email = entity.GetAttributeValue("emailaddress1").ToString();
//handle the above line of code accordingly based on dataType(String, EntityReference, Datetime etc.)
QueryExpression contactQuery = new QueryExpression("contact");
contactQuery.ColumnSet = new ColumnSet("emailaddress1");
contactQuery.Criteria.AddCondition("emailaddress1", ConditionOperator.Equal, email);
EntityCollection contactColl = service.RetrieveMultiple(contactQuery);
if (contactColl.Entities.Count > 0)
{
throw new Exception("Duplicates found !!!");
}
}
}
catch (Exception ex)
{
throw (ex);
}
}
#endregion
}
}
}