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)

Unexpected exception from plug-in (Execute)

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

I am new to C# and Custom Workflow in MS CRM.

I've created one workflow to get record guid as a result, to put in the lookup field on Opportunity. when the workflow executed it raise an error like this.

Unexpected exception from plug-in (Execute): IBS.MSCRM.IBSConstruction.FetchXMLReturnConsProjectParticipant: System.IO.FileNotFoundException: Could not load file or assembly 'IBS.MSCRM.Core.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3d22e7ae6a0b3afb' or one of its dependencies. The system cannot find the file specified.

and here is the Error Detail

Plugin Trace:

[IBS.MSCRM.IBSConstruction: IBS.MSCRM.IBSConstruction.FetchXMLReturnConsProjectParticipant]
[IBS.MSCRM.IBSConstruction (1.0.0.0): IBS.MSCRM.IBSConstruction.FetchXMLReturnConsProjectParticipant]

Error Message:

Unhandled Exception: Microsoft.Crm.CrmException: Unexpected exception from plug-in (Execute): IBS.MSCRM.IBSConstruction.FetchXMLReturnConsProjectParticipant: System.IO.FileNotFoundException: Could not load file or assembly 'IBS.MSCRM.Core.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3d22e7ae6a0b3afb' or one of its dependencies. The system cannot find the file specified.
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)

I don't know what's the problem. I have de-register and register the plugin, but this error still occurs.

here is my code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Crm.Sdk;
using IBS.MSCRM.Core.Library;


namespace IBS.MSCRM.IBSConstruction
{
    public sealed class FetchXMLReturnConsProjectParticipant : CodeActivity
    {
        [Input("FetchXMLQuery")]
        public InArgument<string> fetchxmlquery { get; set; }

        [Input("FieldName")]
        public InArgument<string> fieldname { get; set; }

        [Output("Result")]
        [ReferenceTarget("ibs6052c_consprojectparticipant")]
        public OutArgument<EntityReference> result { get; set; }


        protected override void Execute(CodeActivityContext context)
        {
            Crud crm = new Crud(context);
            var res = crm.FetchXML(this.fetchxmlquery.Get(context));
            crm.ts.Trace("Query result count: " + res.TotalRecordCount);
            crm.ts.Trace("Query result entity name: " + res.EntityName);
            if (res.Entities.Count > 0)
            {
                //Implement your function here...

                Guid consProjPartID = Guid.Empty;

                Entity consProjPart = (Entity)res.Entities.FirstOrDefault();
                consProjPartID = consProjPart.Id;

                this.result.Set(context, consProjPartID);

                //Implement your function here...
            }
            else
                this.result.Set(context, null);
        }
    }
}


can you all give me feedback and suggestion about my code?

Thanks & Regards.

Rico

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sartaj Profile Picture
    880 on at

    Hi Rico,

    The problem is that within custom workflow you are using external library (IBS.MSCRM.Core.Library) which is actually not present on the crm server where the workflow is executing, hence File Not Find Exception.

    You can opt any one of the below method to overcome this issue:

    1- If you are working on-premises MS Dynamics CRM, place this library (IBS.MSCRM.Core.Library) in GAC of CRM server.

    2- You can also merge this library with you plugins' dll using ILMerge. Please find below link for the step by step process.

    http://nicknow.net/dynamics-crm-ilmerge-dll-plugin/

    Hope this help, thanks.

    Sartaj

  • Sartaj Profile Picture
    880 on at

    Hi Rico,

    Are you able to call you custom workflow now?

    Sartaj

  • Community Member Profile Picture
    on at

    Hi Sartaj,

    thanks for your reply.

    now my custom workflow works good.

    it is my mistake about adding reference. I already install the ILMerge, but my mistake to add dll reference so it's not merged.

    Thanks & Regards,

    Rico

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