Hello, I have been having a huge issue all day. I cannot get my custom workflow to profile. I have:
- redownloaded the SDK
- uninstalled and reinstalled the plugin in profiler
- tried tracing (even that's not catching)
Please help. We have Dynamics 365 On Premise V9. I am using SDK V9. Other plugins have no other issue, I can profile and everything, but nothing is working for custom workflows. I can register everything fine, but when i go profile, i get this error. Here is the error message:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unable to load plug-in assembly.
Detail: <OrganizationServiceFault xmlns="">schemas.microsoft.com/.../Contracts" xmlns:i="">www.w3.org/.../XMLSchema-instance">
<ActivityId>dc80b3de-fe94-4982-a051-e12acee5acf1</ActivityId>
<ErrorCode>-2147204719</ErrorCode>
<ErrorDetails xmlns:a="">schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<a:key>ApiExceptionSourceKey</a:key>
<a:value i:type="b:string" xmlns:b="">www.w3.org/.../a:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<a:key>ApiOriginalExceptionKey</a:key>
<a:value i:type="b:string" xmlns:b="">www.w3.org/.../XMLSchema">Microsoft.Crm.CrmException: Unable to load plug-in assembly. ---> Microsoft.Crm.CrmException: Unable to load plug-in assembly.
at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.LoadCrmPluginAssemblyMetadata(IBusinessEntity pluginAssembly, ExecutionContext context, Boolean loadAllMetadata)
at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.RetrieveAssemblyMetadata(IBusinessEntity pluginAssembly, ExecutionContext context, Boolean retrieveFromExisting, Boolean forSystemAssembly)
at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.ValidateOperation(String operationName, IBusinessEntity entity, ExecutionContext context)
at Microsoft.Crm.ObjectModel.SdkEntityServiceBase.CreateInternal(IBusinessEntity entity, ExecutionContext context, Boolean verifyAction)
--- End of inner exception stack trace ---
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.Pipeline.<>c__DisplayClass2_1.<Execute>b__0()</a:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<a:key>ApiStepKey</a:key>
<a:value i:type="b:guid" xmlns:b="">schemas.microsoft.com/.../a:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<a:key>ApiDepthKey</a:key>
<a:value i:type="b:int" xmlns:b="">www.w3.org/.../a:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<a:key>ApiActivityIdKey</a:key>
<a:value i:type="b:guid" xmlns:b="">schemas.microsoft.com/.../a:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<a:key>ApiPluginSolutionNameKey</a:key>
<a:value i:type="b:string" xmlns:b="">www.w3.org/.../a:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<a:key>ApiStepSolutionNameKey</a:key>
<a:value i:type="b:string" xmlns:b="">www.w3.org/.../a:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<HelpLink i:nil="true" />
<Message>Unable to load plug-in assembly.</Message>
<Timestamp>2020-07-14T20:02:48.5498299Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault>
<ActivityId>dc80b3de-fe94-4982-a051-e12acee5acf1</ActivityId>
<ErrorCode>-2147204719</ErrorCode>
<ErrorDetails xmlns:a="">schemas.datacontract.org/.../System.Collections.Generic" />
<HelpLink i:nil="true" />
<Message>Unable to load plug-in assembly.</Message>
<Timestamp>2020-07-14T20:02:48.5498299Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at PluginProfiler.Library.ProfilerManagementUtility.CreateWorkflowAssembliesAndTypes(CrmServiceClient service, ActivityAssemblyCompilerConfiguration configuration, Dictionary`2 types, OptionSetValue isolationMode, DateTime lastModified, IEnumerable`1 mappedAssemblies)
at PluginProfiler.Library.ProfilerManagementUtility.InstrumentWorkflowSteps(CrmServiceClient service, Guid workflowId, String keyFileName, CustomActivityStep[] workflowSteps)
at PluginProfiler.Library.ProfilerManagementUtility.EnableWorkflow(CrmServiceClient service, String overrideKeyFileName, Guid workflowId, Boolean persistToEntity, String persistenceSessionKey, Boolean includeSecureInformation, Boolean isContextReplay, CustomActivityStep[] workflowSteps)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel.btnOk_Click()
I am using the target framework .NET Framework 4.6.2; I have added the two Microsoft NuGet packages Microsoft.CrmSdk.CoreAssemblies and Microsoft.CrmSdk.Workflow. I have even tried downgrading these and trying again, but i get the same error.
I am registering the assembly in the database. Even still, I have checked our server and they do contain the necessary .dlls. Even if I try registering it to disk (after adding my custom .dll to the folder on the server), I still get this error.
Again, I have tried tracing, adding it even before the Try, throughout the Try, and in the Catch. Still even when I turn tracing to All in the system, nothing is traced.
Please help as I have to release this on Thursday and I have no idea why this is happening. I have never had this issue in the past. Below is my code:
Thanks!!!
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Activities;
using System.ServiceModel;
namespace CreateNexteCOAProofTask_cwa
{
public class CreateNexteCOAProofTask_cwa : CodeActivity
{/// <summary>
/// Custom workflow that runs when a eCOA Proofreading Task is completed and the eCOA Approved field is "No". This will create the next eCOA Proofreading Task with the next round number.
/// Runs from "" Workflow
/// Dependency:
/// </summary>
/// <param name="executionContext"></param>
[Input("Dummy Argument for Profiler")]
[Default("Dummy Argument for Profiler")]
public InArgument<string> DummyArgument { get; set; }
protected override void Execute(CodeActivityContext executionContext)
{
ITracingService tracingService = (ITracingService)executionContext.GetExtension<ITracingService>();
tracingService.Trace("Execute 'CreateNexteCOAProofTask_cwa' Custom Workflow was fired");
try
{
tracingService.Trace("Tracing: TRY");
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService orgservice = serviceFactory.CreateOrganizationService(context.UserId);
OrganizationServiceContext orgcontext = new OrganizationServiceContext(orgservice);
Entity prevTask = orgservice.Retrieve("task", context.PrimaryEntityId, new ColumnSet("cti_ecoaround", "subject", "cti_ecoavendor", "cti_task", "statuscode", "ownerid", "cti_instructions_task", "cti_deliverynotes", "description", "regardingobjectid", "cti_department", "cti_instructions_job"));
tracingService.Trace("Tracing - Entity Attributes Count: {0}", prevTask.Attributes.Count.ToString());
foreach (var attribute in prevTask.Attributes)
{
tracingService.Trace("Tracing - Key: {0} - Value: {1}", attribute.Key, attribute.Value);
}
Entity NextTask = CreateNextTask(orgservice, prevTask);
orgservice.Create(NextTask);
tracingService.Trace("Task Created");
tracingService.Trace("Tracing - END");
}
catch (FaultException<OrganizationServiceFault> e)
{
tracingService.Trace("jobcreation_cwa: {0}", e.ToString());
}
catch (InvalidWorkflowException e)
{
tracingService.Trace("jobcreation_cwa: {0}", e.ToString());
}
catch (Exception e)
{
tracingService.Trace("jobcreation_cwa: {0}", e.ToString());
}
}
protected Entity CreateNextTask(IOrganizationService orgservice, Entity prevTask)
{
try
{
InitializeFromRequest initialize = new InitializeFromRequest();
initialize.TargetEntityName = "task";
initialize.EntityMoniker = new EntityReference("task", prevTask.GetAttributeValue<Guid>("activityid"));
InitializeFromResponse response = (InitializeFromResponse)orgservice.Execute(initialize);
if (response.Entity != null)
{
Entity Task = response.Entity;
int NextRound = Task.GetAttributeValue<int>("cti_ecoaround") + 1;
Task.Attributes.Add("cti_ecoaround", NextRound);
Task.Attributes.Add("cti_deliverystatus", new OptionSetValue(100000000));
Task.Attributes.Add("cti_task", new OptionSetValue(100000070));
Task.Attributes.Add("statuscode", new OptionSetValue(100000000));
Task.Attributes.Add("cti_ecoavendor", prevTask.GetAttributeValue<EntityReference>("cti_eprovendor"));
Task.Attributes.Add("ownerid", (prevTask.GetAttributeValue<EntityReference>("ownerid")));
Task.Attributes.Add("regardingobjectid", prevTask.GetAttributeValue<EntityReference>("regardingobjectid"));
Task.Attributes.Add("cti_instructions_task", prevTask.GetAttributeValue<string>("cti_instructions_task"));
Task.Attributes.Add("cti_deliverynotes", prevTask.GetAttributeValue<string>("cti_deliverynotes"));
Task.Attributes.Add("description", prevTask.GetAttributeValue<string>("description"));
Task.Attributes.Add("cti_instructions_job", prevTask.GetAttributeValue<string>("cti_instructions_job"));
Task.Attributes.Add("cti_department", new EntityReference("cti_department", new Guid("F50CB9B2-E158-EA11-8432-00155D64622A")));
return Task;
}
else
{
throw new Exception("Failed To Create Next Task");
}
}
catch (Exception e)
{
throw new Exception("Failed To Create Next Task!");
}
}
}
}