locked
Plugin error - Could not load file or assembly Microsoft.Xrm.Client RRS feed

  • Question

  • Hi all.  I have two plugins that are virtually identical, and one runs without issue but the other is giving this error when it runs:

    >Exception when trying to create record for BulkOperationid{784E64E4-B7F8-E411-80B5-0050568464EA}, entityid  {5D7FFEF3-EF98-E311-9405-005056843A84}, exception : Microsoft.Crm.CrmException: 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. ---> System.IO.FileNotFoundException: 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.

    The one that works is running on a custom entity, and the one that's failing is running on the Email entity on Create Pre-Operation.  This is CRM 2013 RU1 SP1 On Site. 

    I tried copying Microsoft.Xrm.Client.dll into C:\Program Files\Microsoft Dynamics CRM\Server\bin on the server, but I got the same results.  I'm just not sure why it's working without issue on one plugin but not on another.  

    Update:  I'm trying to create the emails through a Quick Campaign, and the System Job is showing "An unexpected error occurred from ISV code" (0x80040224) when the email should be created.  I can however create an Email by itself in CRM and the plugin runs.  It appears to only fail when i create the email through a Quick Campaign.

    Update2: I changed the plugin to run Pre-Valiation instead of Pre-Operation, and now I get this error "An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support" 80040216, but i'm still getting the assembly not found error.

    Thanks for any insight.



    • Edited by Sam Alex Tuesday, May 12, 2015 4:03 PM
    Tuesday, May 12, 2015 3:15 PM

Answers

  • Given that the error relates to not being able to load the assembly, I would assume that the plugin that works does not use the Microsoft.Xrm.Client.dll assembly.

    The Microsoft.Xrm.Client.dll assembly is dependent on the Microsoft.Xrm.Sdk.Deployment assembly, so that will need to be available (from C:\Program Files\Microsoft Dynamics CRM\Server\bin or the GAC). It's also worth checking the versions of all these files to be sure.

    In general, it is best not to use the Microsoft.Xrm.Client.dll assembly in a plugin, due to issues like this, and that it can't run in the sandbox. Is there any reason you're using this, rather than the IOrganizationService instance that you can derive from the plugin context ?


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by Sam Alex Thursday, May 14, 2015 3:02 PM
    Tuesday, May 12, 2015 4:14 PM
    Moderator

All replies

  • Given that the error relates to not being able to load the assembly, I would assume that the plugin that works does not use the Microsoft.Xrm.Client.dll assembly.

    The Microsoft.Xrm.Client.dll assembly is dependent on the Microsoft.Xrm.Sdk.Deployment assembly, so that will need to be available (from C:\Program Files\Microsoft Dynamics CRM\Server\bin or the GAC). It's also worth checking the versions of all these files to be sure.

    In general, it is best not to use the Microsoft.Xrm.Client.dll assembly in a plugin, due to issues like this, and that it can't run in the sandbox. Is there any reason you're using this, rather than the IOrganizationService instance that you can derive from the plugin context ?


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by Sam Alex Thursday, May 14, 2015 3:02 PM
    Tuesday, May 12, 2015 4:14 PM
    Moderator
  • I've built the classes with CrmSvcUtil.exe to do early binding and these seem to require the Microsoft.Xrm.Client.dll assembly.  I'm using a framework built by another developer, and this is heavily dependent on the classes built from CrmSvcUtil.exe so I can't easily remove them.  Is there any issue with adding Microsoft.Xrm.Client.dll and Microsoft.Xrm.Sdk.Deployment to the CRM bin folder on the server for these to work?  
    Tuesday, May 12, 2015 4:55 PM
  • I rebuilt xrm.cs without Microsoft.Xrm.Client and removed the reference.  I'm no longer getting the error I was before, but now I'm getting this:

    [2015-05-12 15:12:19.950] Process:Microsoft.Crm.Sandbox.WorkerProcess |Organization:2e3f3542-e2f8-e411-80b5-0050568464ea |Thread:   18 |Category: Sandbox |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId:  | SandboxWorker.Execute  ilOffset = 0x2F
    >SandboxWorker: Execute failed for worker process: 3036 for org: 2e3f3542-e2f8-e411-80b5-0050568464ea with exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: System.IO.FileNotFoundException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #3EEB6DD1 

    The plugin still works fine with just creating a single Email, but when emails are created through a Campaign I get this.  What I don't get is I don't have the plugin registered in the sandbox, the Isolation Mode is set to NONE in Plugin Registration Tool.  Any thoughts?  When I look at the Quick Campaign Job it shows Failure for all the emails it should've created with this error:

    An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support - 0x80040216

    I even unregistered and reregistered the Plugin, plus I searched the entire solution for Microsoft.Xrm.Client and nothing showed up so I know it's removed.

    Thanks for any insight.

    Tuesday, May 12, 2015 9:54 PM
  • I think the sandbox may come into play because the quick campaign distribution process may run in the sandbox - when isolation mode = 'None', it means the plugin will be loaded into the process of whatever initiated the action, which is normally the application pool, but could be the sandbox or async service.

    The error message does not specify which file cannot be loaded, but it is most likely to be an assembly. Have you removed the reference to Microsoft.Xrm.Client within your plugin assembly, and are there any other references in the assembly (other than those in the .Net Framework, Microsoft.Xrm.Sdk and Microsoft.Crm.Sdk.Proxy) ?


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, May 13, 2015 11:10 AM
    Moderator
  • I found that another plugin was actually continuing to create an error after I removed everything from thsi plugin that was not related to Microsoft.Xrm.Sdk.  So removing Microsoft.Xrm.Client and the other dependencies did fix the issue without having to move anything else to the server.

    Thanks-

    Thursday, May 14, 2015 3:04 PM
  • It was another plugin causing the sandbox error.  I inactivated it and my initial plugin minus the extra references worked like a champ.  Thanks.
    Thursday, May 14, 2015 3:04 PM