locked
Plugin with Early Bound Types Error RRS feed

  • General discussion

  • Every time I try to debug my plugin I get this error:

    Business Process Error
    Could not load file or assembly 'Microsoft.Xrm.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    Thursday, March 6, 2014 1:38 PM

All replies

  • Hi bishoycom,

    Try  copying the "Microsoft.Xrm.Client.dll" from the CRM SDK to GAC and CRM bin folder (where CRM files are installed).


    Admin QuikView Solution for CRM 2013

    Thursday, March 6, 2014 2:54 PM
  • I copied the "Microsoft.Xrm.Client.dll" from the CRM SDK to GAC and CRM bin folder.

    The previous error has gone but another one appeared:

    {"The value 'Microsoft.Xrm.Client.Configuration.CrmConfigurationProvider, Microsoft.Xrm.Client' is not recognized as a valid type or is not of the type 'Microsoft.Xrm.Client.Configuration.CrmConfigurationProvider'."}

    ----------------------------------------------------------

    My Code is:

    using System;
    using System.Collections.ObjectModel;
    using System.Globalization;
    using System.Linq;
    using System.ServiceModel;
    using Microsoft.Xrm.Sdk;
    using Xrm;
    using Microsoft.Xrm.Sdk.Query;
    using Microsoft.Xrm.Client;

    namespace OpenCasePluginXrm
    {
        public class Plugin : IPlugin
        {
            public void Execute(IServiceProvider serviceProvider)
            {
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    Entity entity = (Entity)context.InputParameters["Target"];
                    if (entity.LogicalName != "incident") { return; }
                    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                    try
                    {
                        if (context.MessageName == "Create")
                        {
                            var customerid = ((EntityReference)entity.Attributes["customerid"]).Id;

                            CrmConnection conn = new CrmConnection("SparktechConnection");
                            XrmServiceContext xrm = new XrmServiceContext(conn);
                            Contact contact = xrm.ContactSet.Single(c => c.ContactId == customerid);
                        }
                    }
                    catch (FaultException<OrganizationServiceFault> ex)
                    {
                        throw new InvalidPluginExecutionException("An error occurred in MyPlug-in.", ex);
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
            }

        }
    }

    ----------------------------------------------------------

    The line which produce the error is this line

    CrmConnection conn = new CrmConnection("SparktechConnection");

    ----------------------------------------------------------

    App.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <connectionStrings>
        <add name="SparktechConnection" connectionString="Url=http://devenv/Default/XRMServices/2011/Organization.svc; Username=dev\bgeorge; Password=****;"/>
      </connectionStrings>
    </configuration>

    Friday, March 7, 2014 12:23 AM
  • Could you tell us a bit more about your plugin? Code, dependencies etc.

    If this post is an answer or helpful, please do not forget to vote!

    Friday, March 7, 2014 9:19 AM
  • which debugging way you used? Try to copy all of dll you used into crm\bin folder. In my opinion "CrmConnection" isn't a OOB class, so i think it referenced others assemblies.

    Or change your code as below

       //CrmConnection conn = new CrmConnection("SparktechConnection");
                             XrmServiceContext xrm = new XrmServiceContext(service);
                             Contact contact = xrm.ContactSet.Single(c => c.ContactId == customerid);

    but the other strange problem is that we can't use XrmServiceContext  in plugin.
    • Edited by Chen Xiong Friday, March 7, 2014 10:12 AM
    Friday, March 7, 2014 10:11 AM