web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Plugin Registration Tool errors when updating Custom Activity

(0) ShareShare
ReportReport
Posted on by
Hello there,
 
I'm relatively new at developing the CRM and right now my plugin registration tool seems to work only when I register a new plugin or custom activity. When I try updating though, it always throws an error. That's obviously very annoying as I would have to copy and paste the code into a new assembly every time I make changes to test the activity. Here is the error thrown:
 
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Assembly can not be loaded.
Detail: <OrganizationServiceFault xmlns=/http://schemas.microsoft.com/xrm/2011/Contracts/ xmlns:i=/http://www.w3.org/2001/XMLSchema-instance/>
  <ActivityId>b444e52e-c7b7-4a22-9c05-1f9f5b978234</ActivityId>
  <ErrorCode>-2147200995</ErrorCode>
  <ErrorDetails xmlns:a=/http://schemas.datacontract.org/2004/07/System.Collections.Generic/>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionSourceKey</a:key>
      <a:value i:type=/b:string/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>Plugin/Microsoft.Crm.ObjectModel.PluginTypeService</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiOriginalExceptionKey</a:key>
      <a:value i:type=/b:string/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>Microsoft.Crm.CrmException: Assembly can not be loaded. ---&gt; Microsoft.Crm.CrmException: Assembly can not be loaded.
   at Microsoft.Crm.Workflow.ObjectModel.CustomActivityInfoMetadataBase.GetCustomActivityInfo(ActivityInfo activityInfo, Int32 isolationMode, Guid pluginAssemblyId)
   at Microsoft.Crm.ObjectModel.PluginTypeServiceInternal`1.SetIsWorkFlowActivityAttribute(PluginType pluginTypeArg, IBusinessEntity PluginAssembly, SandboxCustomActivityInfo&amp; customActivityInfo, CrmPluginTypeMetadata&amp; typeMetadata, ExecutionContext Context)
   at Microsoft.Crm.ObjectModel.PluginTypeServiceInternal`1.Create(IBusinessEntity entity, ExecutionContext context)
   --- 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.&lt;&gt;c__DisplayClass3_0.&lt;RunStep&gt;b__0()</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiStepKey</a:key>
      <a:value i:type=/b:guid/ xmlns:b=/http://schemas.microsoft.com/2003/10/Serialization//>3dcabb1b-ea3e-db11-86a7-000a3a5473e8</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiDepthKey</a:key>
      <a:value i:type=/b:int/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>1</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiActivityIdKey</a:key>
      <a:value i:type=/b:guid/ xmlns:b=/http://schemas.microsoft.com/2003/10/Serialization//>b444e52e-c7b7-4a22-9c05-1f9f5b978234</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiPluginSolutionNameKey</a:key>
      <a:value i:type=/b:string/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>System</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiStepSolutionNameKey</a:key>
      <a:value i:type=/b:string/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>System</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionCategory</a:key>
      <a:value i:type=/b:string/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>ClientError</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionMesageName</a:key>
      <a:value i:type=/b:string/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>CustomActivityInvalid</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionHttpStatusCode</a:key>
      <a:value i:type=/b:int/ xmlns:b=/http://www.w3.org/2001/XMLSchema/>400</a:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <HelpLink>http://go.microsoft.com/fwlink/?LinkID=398563&amp;error=Microsoft.Crm.CrmException%3a8004501d&amp;client=platform</HelpLink>
  <Message>Assembly can not be loaded.</Message>
  <Timestamp>2023-06-20T16:20:36.0283954Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil=/true/ />
  <InnerFault>
    <ActivityId>b444e52e-c7b7-4a22-9c05-1f9f5b978234</ActivityId>
    <ErrorCode>-2147200995</ErrorCode>
    <ErrorDetails xmlns:a=/http://schemas.datacontract.org/2004/07/System.Collections.Generic/ />
    <HelpLink i:nil=/true/ />
    <Message>Assembly can not be loaded.</Message>
    <Timestamp>2023-06-20T16:20:36.0283954Z</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 Microsoft.Crm.Tools.Libraries.RegistrationHelper.RegisterPlugin(CrmOrganization org, CrmPlugin plugin)
   at Microsoft.Crm.Tools.AssemblyRegistration.PluginRegistrationViewModel.RegisterAssembly()
 
 
That error code by the way, when I look it up on Web service error codes: -2147200995 simply says /Invalid Custom Activity/ which is not very specific.
 
But if there is an error with my activity please let me know. I have posted the code below, which by the way it doesn't seem to work (when it registered successfully the first time). What this code tries to do is to make an API call to this third party company called Initium and get a standardized address. Then for testing, I want to put part of that address on some text field in the Address form of Dynamics by using a workflow. The API call part itself was tested pretty well against the Console and of course I put /CONFIDENTIAL/ where I should not expose some ids provided to me and my org. But here it is:
 
 
using System;
using System.Collections.Generic;
using RestSharp;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using System.Globalization;
using System.Workflow;
using System.Activities;
 
namespace WheatonPluginDelta.Activities
{
    //Main Program:
    public class InstantAddress : CodeActivity
    {
        //For parsing Token:
        public partial class TokenAcquisition
        {
            [JsonProperty(/Token/)]
            public string Token { get; set; }
        }
        //For parsing Response: AddressItems is main Root, which contains a list which also constains a dict.
        public partial class AddressItems
        {
            [JsonProperty(/InstantAddressResult/)]
            public InstantAddressResult[] InstantAddressResult { get; set; }
        }
        public partial class InstantAddressResult
        {
            [JsonProperty(/StandardizedAddress/)]
            public Dictionary<string, string> StandardizedAddress { get; set; }
            [JsonProperty(/InstantAddressResponse/)]
            public InstantAddressResponse[] InstantAddressResponse { get; set; }
        }
        public partial class StandardizedAddress
        {
            [JsonProperty(/Street1/)]
            public string Street1 { get; set; }
            [JsonProperty(/Street2/)]
            public string Street2 { get; set; }
            [JsonProperty(/Street3/)]
            public string Street3 { get; set; }
            [JsonProperty(/City/)]
            public string City { get; set; }
            [JsonProperty(/State/)]
            public string State { get; set; }
            [JsonProperty(/ZipCode/)]
            public string ZipCode { get; set; }
            [JsonProperty(/Country/)]
            public string Country { get; set; }
        }
        public partial class InstantAddressResponse
        {
            [JsonProperty(/AdditionalElements/)]
            public AdditionalElement[] AdditionalElements { get; set; }
        }
        public partial class AdditionalElement
        {
            [JsonProperty(/Value/)]
            public string Value { get; set; }
        }
        
        [Output(/MailingLabel/)]
        public OutArgument<string> MailingLabel { get; set; }

        
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();
            IWorkflowContext workflowContext = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService orgService = serviceFactory.CreateOrganizationService(workflowContext.UserId);
            
            //From INITIUM software: Token acquisition
            var options1 = new RestClientOptions(https://addressvalidation.initiumsoftware.com/)
            {
                MaxTimeout = -1,
            };
            var client1 = new RestClient(options1);
            var request1 = new RestRequest(/api/auth/tokenacquisition/, Method.Post);
            request1.AddHeader(/Content-Type/, /application/json/);
            var body1 = @/  /*If you copy and paste this snippet please remember to remove comments, to avoid any issues.*// + /// +
            @/  {/ + /// +
            //Must input updated accesskey and Appid:
            @/    //AccessKey//: //CONFIDENTIAL//,/*Key provided by Initium Software. Used in conjunction with the AppId to authenticate.*// + /// +
            @/    //AppId//: //CONFIDENTIAL//,/*ID provided by Initium Software. Used in conjunction with the AccessKey to authenticate.*// + /// +
            @/    //ApplicationName//: ////, /*Name generated by Initium Software.*// + /// +
            @/    //ApplicationTag//: ////, /*Optional application tag generated by Client.*// + /// +
            @/    //Reference1//: ////,/*Optional Reference field, maximum of 10.*// + /// +
            @/    //Reference2//: ////,/*Optional Reference field, maximum of 10*// + /// +
            @/    //Reference3//: ////,/*Optional Reference field, maximum of 10*// + /// +
            @/    //Reference10//: /////*Optional Reference field, maximum of 10*// + /// +
            @/}/;
            request1.AddStringBody(body1, DataFormat.Json);
            RestResponse response1 = client1.Execute(request1);
            JObject tokenjson = JObject.Parse(response1.Content);
            TokenAcquisition tokenAcquisition = System.Text.Json.JsonSerializer.Deserialize<TokenAcquisition>(tokenjson.ToString()); //must have jsonobject.ToString()
            var token = tokenAcquisition.Token;
            //Must pull address variables from CRM and assign:
            string st1 = /2414 W Lexington/;
            string zip = /60612/;
            //From INITIUM Software Single Address Validation:
            var options = new RestClientOptions(https://addressvalidation.initiumsoftware.com/)
            {
                MaxTimeout = -1,
            };
            var client = new RestClient(options);
            var request = new RestRequest(/api/core/getaddress/, Method.Post);
            request.AddHeader(/token/, token);
            request.AddHeader(/Content-Type/, /application/json/);
            var body = @/{  //Street1//: / + $/'{st1}',/
 + /// +
            @/ //Street2//: ////,
/ + /// +
            @/  //Street3//: ////,
/ + /// +
            @/  //Street4//: ////,
/ + /// +
            @/  //Street5//: ////,
/ + /// +
            @/  //City//: ////,
/ + /// +
            @/  //State//: ////,
/ + /// +
            @/  //ZipCode//: / + $/'{zip}',/
 + /// +
            @/  //Country//: //USA//,
/ + /// +
            @/  ////ResponseType//://Formatted//, 
/ + /// +
            @/  //ResponseType//://Full//,  
/ + /// +
            @/  ////ResponseType//://Default// 
/ + /// +
            @/  ////ResponseType//://Formatted// 
/ + /// +
            @/  ////ResponseType//://Standardized//   
/ + /// +
            @/  ////IntegratorNotes//: true
/ + /// +
            @/}
/ + /// +
            @/
/ + /// +
            @/
/ + /// +
            @/      /;
            request.AddStringBody(body, DataFormat.Json);
            RestResponse response = client.Execute(request);
            JObject addressjson = JObject.Parse(response.Content);
            AddressItems addressItems = System.Text.Json.JsonSerializer.Deserialize<AddressItems>(addressjson.ToString()); //must have o.ToString()
            var street1 = addressItems.InstantAddressResult[0].StandardizedAddress[/Street1/];
            var street2 = addressItems.InstantAddressResult[0].StandardizedAddress[/Street2/];
            var street3 = addressItems.InstantAddressResult[0].StandardizedAddress[/Street3/];
            var city = addressItems.InstantAddressResult[0].StandardizedAddress[/City/];
            var state = addressItems.InstantAddressResult[0].StandardizedAddress[/State/];
            var zipcode = addressItems.InstantAddressResult[0].StandardizedAddress[/ZipCode/];
            var country = addressItems.InstantAddressResult[0].StandardizedAddress[/Country/];
            var county = addressItems.InstantAddressResult[0].InstantAddressResponse[0].AdditionalElements[18].Value;
            string fulladdress = street1 + / / + street2 + / / + street3 + / / + city + / / + country + / / + state + / / + zipcode + / / + county;
            //Console.Write(street1);
            //Console.Read();
            MailingLabel.Set(executionContext, street1.ToString());
        }
    }
}
 
Any help would be very highly appreciated.
 
Thank you.
I have the same question (0)
  • TKoller Profile Picture
    181 on at
    I had this, too.
    Had to restart the "Dynamics 365 Sandbox Processing Service" everytime I wanted to update an plugin workflowactivity...annoying but worked...did you find another solution?
     
    Best Regards
    Tobias
  • Community member Profile Picture
    2 on at
    In my case, I solved this by deleting the presentation framework reference. Maybe it works for you.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 51 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans