Search code examples
dynamics-crmdynamics-crm-online

Why Am I Not Able to Register My CRM Custom Workflow Activity?


I was able to successfully register my workflow assembly, but received the error below when attempting to register my custom workflow activity. This resulted in my workflow Assembly being in CRM, but containing no Custom Code Activities within it.

Unhandled Exception: System.ServiceModel.FaultException Plug-in assembly does not contain the required types or assembly content cannot be updated.

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 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity) at Xrm.Sdk.PluginRegistration.Forms.PluginRegistrationForm.btnRegister_Click(Object sender, EventArgs e)

Detail:

<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ActivityId>5940962f-8dad-45bd-95f5-d9bdacab5c36</ActivityId>
  <ErrorCode>-2147204725</ErrorCode>
  <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>Plug-in assembly does not contain the required types or assembly content cannot be updated.</Message>
  <Timestamp>2018-09-07T12:08:17.3337398Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil="true" />
  <InnerFault>
    <ActivityId>5940962f-8dad-45bd-95f5-d9bdacab5c36</ActivityId>
    <ErrorCode>-2147204725</ErrorCode>
    <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>Plug-in assembly does not contain the required types or assembly content cannot be updated.</Message>
    <Timestamp>2018-09-07T12:08:17.3357419Z</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>

Solution

  • My Custom Workflow Activity inherited from a generic base class. This isn't support by CRM:

    public class MyWorkflow: MyWorkflowBase<int>
    {
        #region Overrides of CodeActivity
    
        protected override void Execute(CodeActivityContext context) { throw new NotImplementedException(); }
    
        #endregion
    }
    
    public abstract class MyWorkflowBase<T> : CodeActivity
    {
    
    }
    

    I basically had to convert my Generic T to be an interface, and cast the actual type as needed, which is less then ideal. Plugins don't suffer from this fate, because it is just looking for the implementation of IPlugin (Which, if you use a generic base class, you'll have to explicitly declare is implemented on your plugin class. Defining a base class as implementing IPlugin won't work if you have a generic class in your hierarchy).