We are trying to qualify lead to contact and have written the following code. We have registered it as per screenshot below but getting the error “The plug-in type could not be found in the plug-in assembly”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Crm.Sdk.Messages;
namespace QualifyLead.CRM.Plugins.Lead
{
public class QualifyLead : IPlugin
{
public void Execute(IServiceProvider _serviceProvider)
{
//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService _tracingService =
(ITracingService)_serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
_serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory _serviceFactory = (IOrganizationServiceFactory)_serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService _crmService = _serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity _entity = (Entity)context.InputParameters["Target"];
if (_entity.LogicalName != "lead")
{
return;
}
var _qualifyIntoContactRequest = new QualifyLeadRequest
{
CreateAccount = false,
CreateContact = true,
CreateOpportunity = false,
LeadId = new EntityReference("lead", new Guid()),
Status = new OptionSetValue(1)
};
var _qualifyIntoContactReponse = (QualifyLeadResponse)_crmService.Execute(_qualifyIntoContactRequest);
}
}
}
}
ERROR
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">System.ArgumentNullException: Value cannot be null.
Parameter name: SandboxAppDomainHelper.Execute: The plug-in type could not be found in the plug-in assembly: QualifyLead.QualifyLead</faultstring><detail><OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ActivityId>a32eebac-d116-427c-a40d-a879810df0ab</ActivityId><ErrorCode>-2147220970</ErrorCode><ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/><Message>System.ArgumentNullException: Value cannot be null.
Parameter name: SandboxAppDomainHelper.Execute: The plug-in type could not be found in the plug-in assembly: QualifyLead.QualifyLead</Message><Timestamp>2017-11-07T09:15:43.9104001Z</Timestamp><ExceptionRetriable>true</ExceptionRetriable><ExceptionSource>PluginExecution</ExceptionSource><InnerFault i:nil="true"/><OriginalException>System.ArgumentNullException
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter& workerCounter, Boolean returnTraceInfo)</OriginalException><TraceText>
[QualifyLead: QualifyLead.QualifyLead]
[94894e19-9cc3-e711-8123-70106fa17a61: QualifyLead.QualifyLead: QualifyLead of lead]
</TraceText></OrganizationServiceFault></detail></s:Fault></s:Body></s:Envelope>