This project is read-only.

Getting Started

  • In this article, you will find all of the steps to write your first application using the XrmLibrary.


  1. Download the XrmLibrary.dll and log4net.dll assemblies or download and compile the source code.
  2. Reference the assemblies in a Visual Studio C# project. The target framework of the project must be .NET 4 and the microsoft.crm.sdk.proxy, microsoft.xrm.sdk, and microsoft.xrm.client Microsoft CRM 2011 SDK assemblies should also be referenced.
  3. Add required sections to the Config File.
  4. Code away!

Writing an Application

  • Once the XrmLibrary is added to the project, you will need to add a using statement for it at the top of each class that will use it -
using XrmLibrary;
  • It can also be useful to reference the Extensions library if you plan to use any of the helpful extension methods included. The extension methods require the following libraries -
using System.Linq;
using XrmLibrary.Extensions;

  • To obtain an IOrganizationService, simply type -
using(var service = Services.Instance.OrganizationService)
    // Perform operations with service...

  • If you are referencing multiple organizations in the Config File, you can instantiate multiple service references at the same time -
// Instantiate an IOrganizationService using the 0th ordinal CrmServiceConfiguration.
using(var serviceSource = Services.Instance.OrganizationService)
    // Instantiate a second IOrganizationService using the 1st ordinal CrmServiceConfiguration.
    using(var serviceTarget = Services.Instance.GetOrganizationService(1);
        // Perform operations using serviceSource and serviceTarget.

  • In the example above, you can see that there is a property Services.Instance.OrganizationService which always returns an IOrganizationService configured for the 0th ordinal CrmServiceConfiguration. A method Services.Instance.GetOrganizationService(Int32 ordinal) is also available that can be used to obtain an IOrganizationService of any ordinal from the Config File.

Last edited Oct 26, 2011 at 8:19 PM by cchamberlain, version 9


No comments yet.