Could not load file or assembly ‘Microsoft.Xrm.Client, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.

To fix this error, do the following steps.

  • copy the file from the following folder "SDK\Bin"
  • Paste if in the following folder "program files\Microsoft Dynamics CRM\CRMWeb\bin"

Note: you can download the SDK  from the following link
http://www.microsoft.com/en-us/download/details.aspx?id=24004

Disable Caching for Organization Service In CRM 2011/2013/2015

MS CRM has caching feature but sometimes you want to disable it to get the latest updates,two ways to disable caching
First way - Configuration

Add the following configuration block to the config file of your application

<configSections>

<sectionname="microsoft.xrm.client"type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client"/>

</configSections>

<microsoft.xrm.client>

<contexts>

<addname="Xrm"type="Xrm.XrmServiceContext, Xrm"serviceName="Xrm"/>

</contexts>

<services>

<addname="Xrm"type="Microsoft.Xrm.Client.Services.OrganizationService, Microsoft.Xrm.Client"/>

</services>

</microsoft.xrm.client>
Second Way - Pragmatically

Microsoft.Xrm.Client.Caching.ObjectCacheManager.GetInstance().Clear();

How to solve : A proxy type with the name account has been defined by another assembly

The problem is actually with WCF attempting to deserialize the server response and not being able to identify the correct type. The best method to sort this issue is to pass in the current assembly using Assembly.GetExecutingAssembly() to the ProxyTypesBehavior() while creating the proxy like so

using (serviceProxy = new OrganizationServiceProxy(config.OrganizationUri,
config.HomeRealmUri,
config.Credentials,
config.DeviceCredentials))
{
// This statement is required to enable early-bound type support.
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior(Assembly.GetExecutingAssembly()));
}

XRM Speed Builder for MS CRM

XRM speedy Tool allows migrating existing applications to CRM in a quick way by providing the following :
- Creates custom entities from SQL Server database tables
- Creates attributes from fields from database table fields
- Puts fields on forms.
http://xrmspeedy.codeplex.com/
Thanks to Jason Lattimer for this perfect tool.

Perform left outer join using Fetch XML in MS CRM

This illustration shows you how to use FetchXML queries to perform left outer join.

The following query shows how to query accounts having no leads

<fetch mapping='logical'>
<entity name='account'>
<attribute name='name'/>
<link-entity name='lead' from='leadid' to='originatingleadid' link-type='outer'/>
<filter operator='and'>
<condition entityname='lead' attribute='leadid' operator='null'/>
</filter>
</entity>
</fetch>