How to Generate C# (or VB.NET) Class for CRM 2011 Organisation

When developing against a customised instance of CRM 2011, often you will want to do so against a strongly typed instance of the current CRM 2011 organisation.

To do this, you need to use the crmsvcutil.exe application which will create the a strongly-typed version of the CRM organisation as a separate set of classes.

You’ll find the application in the CRM SDK bin subfolder.

There are a number of options you can see by running

crmsvcutil /?

from a command prompt.

This is what you’ll see:

Full set of options available in the CRM 2011 crmsvcutil utility

CRM 2011 crmsvcutil options

To find your organisation Url, go open up your CRM 2011 organisation, and navigate to the Settings -> Customisations -> Developer Resources area as follows:

How to find the CRM 2011 Developer Resources

Once you’re there, the organisation url can be found by selecting the Organisation Service, as shown in the screenshot below:

How to work out the Dynamics CRM 2011 Organisation Web Service Url

To create the proxy class, enter this into a command prompt from the SDK bin folder:

crmsvcutil /url:http://localhost/[ORGANISATION-SHORT-NAME]/XRMServices/2011/Organization.svc /namespace:MyNameSpace.Here /out:"c:\Projects\MyProject\[ORGANISATION-NAME].cs"

Your machine will whir for a bit and then you’ll see the new (5Mb+!) C# file that has been generated.

To use the file, create a new Visual Studio project, add references to the Microsoft.Crm.Sdk.Proxy.dll and Microsoft.Xrm.Sdk.dll (found in the SDK bin folder) and then you can start developing against the strongly typed CRM object model.

Leave a Reply