The latest version of the Microsoft Dynamics CRM 2011 Software Development Kit includes a new mechanism to generate an OptionSet helper to include in your custom .NET xRM applications. It uses the CrmSvcUtil executable to generate a C# code file with enum definitions for your OptionSets. You can download the latest CRM 2011 SDK from the Microsoft Download Center.
Navigate to \sdk\samplecode\cs\crmsvcutilextensions\generatepicklistenums and open the generatepicklistenums solution in Visual Studio.
Inside Visual Studio, build the entire solution. Close Visual Studio and then modify the generateoptionsets.bat file located inside \sdk\samplecode\cs\crmsvcutilextensions\generatepicklistenums\bin\Debug. We need to edit the url and also include the username and password to connect to the CRM server.
Double-click on generateoptionsets.bat to generate the OptionSets.cs file. Note that this may take some time. After the file is generated, we can include it inside a Visual Studio solution and use the generated enums in our custom applications.
The screenshot below shows how intellisense now picks up the OptionSet enums.
OptionSets.cs also includes definitions for custom OptionSet fields.