Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:16:52+00:00 2026-06-17T15:16:52+00:00

I am looking to build a fairly simple plug in that calculates the amount

  • 0

I am looking to build a fairly simple plug in that calculates the amount of “units” used & remaining.
I have two custom entites bc_learninglicences & bc_llbalance, the plug – in fires on create of bc_llbalance and another for update.

bc_llbalance: Contains
    bc_learninglicense (Look up field on bc_learninglicences / bc_name)
    bc_units (units that are used by this record)

bc_learninglicences: Contains 
    bc_name
    bc_unitsquantity (This is set to the total qty of units)
    bc_unitsused (this needs to inherit the sum of "bc_units" on "bc_llbalance")
    bc_unitsremaining ( simply bc_unitsquantity - bc_unitsused )

Ok so I have included the code which is obviously not finished as I have just been trying to figure out how to get bc_unitsused to inherit the sum…
this code builds without error. however CRM errors:

Unexpected exception from plug-in (Execute): LearningLicenses.LearningLicenses: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Xrm.Client, Version=5.0.9690.2165

I have a short deadline to build this as the system is due to go live soon, however I cannot move forward with this error which I don’t understand…

Either help with error or code/solution will be appreciated at this point as I’m behind on the time frame for this project.

p.s I am new to developing for CRM 2011 with only a few weeks/ few projects experience.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using System.Text.RegularExpressions;
using System.ServiceModel;

namespace LearningLicenses
{
    public class LearningLicenses : IPlugin
    {

        public void Execute(IServiceProvider serviceProvider)
        {
            try
            {

                // Obtain the execution context from the service provider.
                Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
                    serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));

                //Extract the tracing service for use in debugging sandboxed plug-ins.
                ITracingService tracingService =
                    (ITracingService)serviceProvider.GetService(typeof(ITracingService));

                if (context.InputParameters.Contains("Target") &&
                        context.InputParameters["Target"] is Entity)
                 {

                     // Obtain the target entity from the input parmameters.
                     Entity entity = (Entity)context.InputParameters["Target"];

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

                EntityReference a = (EntityReference)entity.Attributes["bc_learninglicense"];// ((EntityReference)targetEntity.Attributes["bc_learninglicense"]).Id;


                if (entity.LogicalName == "bc_llbalance")
                        try
                        {  

                            //fetchxml to get the sum total of estimatedvalue
                            string value_sum = string.Format(@"         
                    <fetch distinct='false' mapping='logical' aggregate='true'> 
                        <entity name='bc_llbalance'>
                            <attribute name='bc_units' alias='units_sum' aggregate='sum' />
                               <filter type='and'>
                                <condition attribute='bc_learninglicense' operator='eq' value='{0}' uiname='' 
                               </filter>
                        </entity>
                    </fetch>", a.Id);

                            FetchExpression fetch = new FetchExpression(value_sum);
                            EntityCollection value_sum_result = service.RetrieveMultiple(fetch);
                            var TotalValue = "";
                            // decimal TotalValue = 0;
                            foreach (var c in value_sum_result.Entities)
                            {
                                TotalValue = ((string)((AliasedValue)c["value_sum"]).Value);
                            }

                            Entity llc = new Entity("bc_learninglicences");
                            llc.Id = a.Id;
                            llc.Attributes.Add("bc_unitsused", TotalValue);

                            service.Update(llc);

                        }
                        catch (FaultException ex)
                        {
                            throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
                        }
                }

            }
            catch (FaultException ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
            }
        }
    }
 }



THE ERROR : 

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): LearningLicenses.LearningLicenses: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9690.2165, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.Detail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220956</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>Unexpected exception from plug-in (Execute): LearningLicenses.LearningLicenses: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9690.2165, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</Message>
  <Timestamp>2013-01-22T10:09:22.0275105Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

[LearningLicenses: LearningLicenses.LearningLicenses]
[c1b35170-c563-e211-8c6d-b499bafd5e5b: LearningLicenses.LearningLicenses: Create of bc_llbalance]


</TraceText>
</OrganizationServiceFault>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:16:53+00:00Added an answer on June 17, 2026 at 3:16 pm

    Microsoft.Xrm.Client is not used by CRM and so is not present in the GAC or anywhere on the CRM server, it is intended to be redistributed with any client applications that require it.

    It shouldn’t need to be referenced in your Plugin assembly at all, so I would remove it and see if any of your code references it. If it does it should be able to be replaced with equivalent code that doesn’t use that assembly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to build a fairly simple plug in that calculates the amount
I have a fairly simple project with only two XIBs, 5 custom classes and
I have been developing a fairly simple app for iOS and Android that parses
Here is what I am looking to do.I have two list of tuples. Build
I have a fairly simple console app that monitors an exchange mailbox, picks particular
I'm looking to build a messaging system that handles conversation much like how Facebook
I'm looking to build an application that will rely on adding menu extensions to
I'm looking to build a flyout type menu in Silverlight that will be added
I'm looking to build a custom view of a Google Maps type of application
I'm looking for an editor/IDE that can provide features that are nice to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.