Plug-In using Caching.ObjectCacheManager ::: Can't register microsoft.xrm.client.dll in GAC RRS feed

  • Question

  • Hi!

    We noticed that CRM 2011 is caching more aggressively than CRM 4.0 used to. We noticed one negative side-effect where sometimes after a Plug-In fires and updates a field, we refresh the form but are presented with old data. I can see that the data is changed immediately by doing an uncommitted Read against our SQL Server database so I know that the Plug-In does fire right away. The delay until we see the updated data on the front-end is anywhere from 2 to 30 seconds. I have also cleared my browser cache and did a CTRL+F5 to ensure it's not client-side caching.

    I looked for a solution to remove the entity record from the CRM cache manually and it seems that this can only be accomplished using the Microsoft.Xrm.Client assembly which isn't usually used for Plug-In development. We store our Plug-In assemblied in the Database and I therefore copied the Microsoft.Xrm.Client.dll in \Server\bin\assembly. I also registered the assembly in the GAC and restarted IIS and the CRM services.

    Yes, I still receive the following error (Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9689.2166, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.) when attempting to get an Instance of the ObjectCacheManager.

    1) Is this in fact a CRM caching problem? Am I misunderstanding the real problem here?

    2) Will removing the record from the cache be the right solution (see code below)?

    3) Why can't it find Microsoft.Xrm.Client despite it being in the \assembly folder AND GAC?

    public static void RemoveSingleEntityRecord(string entityName, Guid entityID)
       const string format = "adxdependency:crm:entity:{0}:{0}id={1}";
       var dependency = string.Format(format, entityName, entityID).ToLower();
       System.Runtime.Caching.ObjectCache cache = Microsoft.Xrm.Client.Caching.ObjectCacheManager.GetInstance();

    Your help is very much appreciated!


    Monday, February 10, 2014 9:10 PM