You’d think this would be easy – just download the SDK and run the utility, right? Sadly that’s not the case and the information to make it work is scattered around the web.

Here are the steps I’ve pieced together from various forum answers and some trial and error.

1. Install Microsoft WIF SDK
You can get it here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=eb9c345f-e830-40b8-a5fe-ae7a864c4d76&displaylang=en

Hint: For Windows 7 and Windows Server 2008 R2, select the msu file with name starting Windows6.1. [Naming it Windows7and2008 would have been too easy I guess.]

2. Install Microsoft Dynamics CRM 2011 SDK

You can get it here: http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=420f0f05-c226-4194-b7e1-f23ceaa83b69

3. Run the DeviceRegistration.exe utility to generate a device id and password

You can find it in the SDK Tools / DeviceRegistration directory.  Run it with command line /Operation:Register

Copy the values for device ID and device password, you’ll need them later

4. Now run CRMSVCUTIL from the MSCRM SDK under the bin directory (not the tools directory)

If you want to copy it to, say, your Utilities directory you’ll need to take all the DLLs with it.   [Someone was apparently too lazy to run ILMerge on it.]

The parameters you’ll need are:

crmsvcutil
   /url:https://<<<Organization>>>.crm4.dynamics.com/XRMServices/2011/Organization.svc
   /o:crm.cs
   /n:<<<Desired namespace name>>>
   /u:<<< your windows live id >>>
   /p:<<< your windows live password >>>
   /serviceContextName:<<<Desired service context name>>>
   /di:<<< Device ID >>>
   /dp: <<< Device Password >>>

5. That’s it!  You should have a file crm.cs that you can use in your Visual Studio Project to interface to MS-CRM.

I just wish it was one step!

6. To add this to your Visual Studio C# Project

Copy the crm.cs file to your solution, add a reference to System.Runtime.Serialization.

Add a /lib folder to your solution and copy the SDK /bin directory into it

Add a reference to the DLLs in there as necessary: Microsoft.XRM.sdk in particular.

Add a reference to System.ServiceModel.