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 CRM (Archived)

Dynamics 365 Plug-In registers correctly, but won't load.

(0) ShareShare
ReportReport
Posted on by 330

I'm trying to register a plug-in to do some custom view creation, and I'm getting an error when opening the site after registering the Assembly and Steps. Here is the log of the error:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #108602C6Detail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
  <ActivityId>e072314e-303a-47f9-a95a-de4f3da9e54a</ActivityId>
  <ErrorCode>-2147220970</ErrorCode>
  <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
  <Message>System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #108602C6</Message>
  <Timestamp>2018-02-20T19:44:04.3421711Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil="true" />
  <InnerFault>
    <ActivityId>e072314e-303a-47f9-a95a-de4f3da9e54a</ActivityId>
    <ErrorCode>-2147204719</ErrorCode>
    <ErrorDetails xmlns:d3p1="schemas.datacontract.org/.../System.Collections.Generic" />
    <Message>Assembly should be provided</Message>
    <Timestamp>2018-02-20T19:44:04.3421711Z</Timestamp>
    <ExceptionRetriable>false</ExceptionRetriable>
    <ExceptionSource i:nil="true" />
    <InnerFault i:nil="true" />
    <OriginalException i:nil="true" />
    <TraceText>

[ActivitySubgridHelper: Cinteros.Crm.ActivitySubgridHelper]
[efa800d1-6b16-e811-80ef-00155d0a4712: Cinteros.Crm.ActivitySubgridHelper: RetrieveMultiple of activitypointer]


</TraceText>
  </InnerFault>
  <OriginalException i:nil="true" />
  <TraceText i:nil="true" />
</OrganizationServiceFault>

I've been unable to get Profiling to work, or Trace Log messages to show up, due to CRM not loading the plug-in. Here is the code of the plug-in I'm trying to use:

using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;

namespace Cinteros.Crm
{
    public class ActivitySubgridHelper : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

#if DEBUG
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = factory.CreateOrganizationService(context.UserId);
#endif
            try
            {
                if (context.MessageName != "RetrieveMultiple" || context.Stage != 20 || context.Mode != 0 ||
                    !context.InputParameters.Contains("Query") || !(context.InputParameters["Query"] is QueryExpression))
                {
                    tracer.Trace("Not expected context");
                    return;
                }
                var query = context.InputParameters["Query"] as QueryExpression;
#if DEBUG
                var fetch1 = ((QueryExpressionToFetchXmlResponse)service.Execute(new QueryExpressionToFetchXmlRequest() { Query = query })).FetchXml;
                tracer.Trace($"Query before:\n{fetch1}");
#endif
                if (ReplaceRegardingCondition(query, tracer))
                {
#if DEBUG
                    var fetch2 = ((QueryExpressionToFetchXmlResponse)service.Execute(new QueryExpressionToFetchXmlRequest() { Query = query })).FetchXml;
                    tracer.Trace($"Query after:\n{fetch2}");
#endif
                    context.InputParameters["Query"] = query;
                }
            }
            catch (Exception e)
            {
                throw new InvalidPluginExecutionException(e.Message);
            }
        }

        private static bool ReplaceRegardingCondition(QueryExpression query, ITracingService tracer)
        {
            if (query.EntityName != "activitypointer" || query.Criteria == null || query.Criteria.Conditions == null || query.Criteria.Conditions.Count < 2)
            {
                tracer.Trace("Not expected query");
                return false;
            }

            ConditionExpression nullCondition = null;
            ConditionExpression regardingCondition = null;

            tracer.Trace("Checking criteria for expected conditions");
            foreach (ConditionExpression cond in query.Criteria.Conditions)
            {
                if (cond.AttributeName == "activityid" && cond.Operator == ConditionOperator.Null)
                {
                    tracer.Trace("Found triggering null condition");
                    nullCondition = cond;
                }
                else if (cond.AttributeName == "regardingobjectid" && cond.Operator == ConditionOperator.Equal && cond.Values.Count == 1 && cond.Values[0] is Guid)
                {
                    tracer.Trace("Found condition for regardingobjectid");
                    regardingCondition = cond;
                }
                else
                {
                    tracer.Trace($"Disregarding condition for {cond.AttributeName}");
                }
            }
            if (nullCondition == null || regardingCondition == null)
            {
                tracer.Trace("Missing expected null condition or regardingobjectid condition");
                return false;
            }
            var regardingId = (Guid)regardingCondition.Values[0];
            tracer.Trace($"Found regarding id: {regardingId}");

            tracer.Trace("Removing triggering conditions");
            query.Criteria.Conditions.Remove(nullCondition);
            query.Criteria.Conditions.Remove(regardingCondition);

            tracer.Trace("Adding link-entity and condition for activity party");
            var leActivityparty = query.AddLink("activityparty", "activityid", "activityid");
            leActivityparty.LinkCriteria.AddCondition("partyid", ConditionOperator.Equal, regardingId);
            return true;
        }
    }
}


I got the above from this page: community.dynamics.com/.../show-all-related-activities-in-a-subgrid

The error appears on the OOB Social Overview Dashboard, on the Activities records view, and any other views using the Activities views, EXCEPT for the one I'm trying to implement it into (which is Contact).

Can anyone see what might be causing this error, and how I can get the assembly to load properly so that I can profile the steps to see if it's doing what I need it to do?

Thank you.

*This post is locked for comments

I have the same question (0)
  • TNS Profile Picture
    1,197 on at

    Hi Chris,

    As you are  getting error "Assembly should be provided". Might be any assembly is missing or if you are using any external assembly which is not available in crm service then add it on C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly.

    If you are not missing any assembly then try this might it help and also check your plugin targets .net4.0 or above.

    So unregister your plugin , then assign new key to your solution(means to your code in Visual Studio) again and build  it. Then register your plugin again. and try.

    If still it does not work then create a new solution an then register again your plugin by unregistering previous  plugin.

    Thanks!

  • C. Dennett Profile Picture
    330 on at

    Hi TNS, and thanks for your reply!

    As ashamed as I am to admit, I'm not quite sure how to do that. I read on another thread that a user had success assigning a new key to the assembly, but they didn't explain how that is done, and I haven't had much success finding instructions. Are you able to help me achieve assigning a new key to my plugin?

    Thank you again for your response.

  • Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    You can also try to change assembly version and try to re-register it(after registering existing one), Select your Project Properties-> click on Assembly Information button and change assembly version, let's make it 1001 and build it.

    Hope it will help

  • C. Dennett Profile Picture
    330 on at

    Thanks for the answers so far, but unfortunately I'm still not able to get it working. I placed the .dll into the server\Program Files\CRM\Server\bin folder, but still received the error. I've attempted to create a blank solution in Visual Studio and add the .cs file to it, but I don't see options for building into an assembly (.dll) or for changing my target .NET version. I'm sorry for my lack of knowledge in this regard, but this is my first go with plug-ins, and I really really want this to work.

    Thank you all for your help, and I hope one of you can see what I'm doing wrong and offer some guidance! :)

  • TNS Profile Picture
    1,197 on at

    Hi Chris,

    Create a class library in visual studio and when you have created and build it  then ->

    go to solution explorer .. on your assembly name  right click then go to properties ... when the properties will open you click on application in left pane ... and then you will find target framework ... please select it .net 4.0 or more  ... and on the left pane there will be signing then ... click on sign the assembly... choose a strong key select new and give name to it your strong key ... again build your solution ...

    go to plugin registeration tool .. register the assembly by selecting your vs solution  dll .. and provide the steps ...

    I hope it will help.. but still you have problem the please tell..

    Thanks!

  • C. Dennett Profile Picture
    330 on at

    Thank you for the very helpful and detailed instructions, TNS. Unfortunately, I am still seeing the issue. I can say for sure that it is being caused by this particular plugin, because if I disable the steps, I don't get the error.

    I did as you suggested, and created a new VS C# Class Library (.NET Framework). NOTE: I did this on my workstation computer, not the Dynamics Application Server that hosts our CRM. I removed the default Class1.cs file from the Solution, and added my .cs file (ActvitySubgridHelper.cs), then tried to build the project. The build failed, because the .cs file has USING statements for the following:

    using Microsoft.Crm.Sdk.Messages;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Query;


    I looked under References to try and add these, but they weren't available, so I went a different route. I created a new VS C# Microsoft Dynamics Solution Template for an Assembly (C#). NOTE: I did this on my workstation computer, not the Dynamics Application Server that hosts our CRM. I removed the sample plugin and workflow from the solution, and added my .cs file, then tried to build the project. The build was successful. I followed the rest of your instructions successfully (targeting .NET 4.5.2) and creating and naming a strong key file. Then I rebuilt the solution and the build was again successful. I remotely accessed our Application Server, and opened the Plugin Registration Tool and connected to the Organization successfully. I chose to register a new Assembly, and when asked to provide the Assembly, I chose the .dll file from my \\Visual Studio 2017\Projects folder on my workstation. The Assembly registered successfully. I then chose to register a new step. The step is configured for the Message RetrieveMultiple on the Entity activitypointer, and is set to run Pre-Operation. The step registered successfully as well. I then went to my Dynamics site, and created a new solution to hold my plugin (in case I needed to quickly disable it). I set up the necessary scenario to get the plugin to run (it triggers anytime an Activities View is loaded), and opened a page that would require running the plugin. The same error as what I posted above popped up.

    Am I missing a step, or perhaps storing files in incorrect locations? The code in the .cs file is sound, and as long as I create the project as an Assembly, all the references seem to be present.

    I very much appreciate everyone's help with this, and really hope that something above lets one of you see what I'm doing wrong. Thank you!

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Chris,

    Can you try with a simple plugin instead of this retrieve multiple plugin? Say a plugin which creates a task record?

    Not sure why but to me it looks like the issue is within the code/logic.

    Thanks,

  • TigerJ Profile Picture
    115 on at

    Three questions:

    What version of D365 are you using (2011, 2015, 2016, 9)?

    What/Where/When did you get your plugin registration tool?

    Where did you get your sdk files?

    These can all impact each other.

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans