Wednesday, 5 March 2014

Create Early Bound Types Library

The following are steps on how to create the early bound types library.

Open Command prompt

Cd to the \SDK\Bin folder of the CRM 2013 sdk

then run the following Command: CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,Microsoft.Xrm.Client.CodeGeneration" /url:https://dttas.api.crm4.dynamics.com/XRMServices/2011/Organization.svc /domain:artscouncil /username:scunningham@DTTAS.onmicrosoft.com /password:###### /out:"Xrm.cs" /namespace:ArtsCouncil.Xrm /serviceContextName:XrmServiceContext /servicecontextprefix:Xrm /generateActions
The command parameters which require input are flagged in red which mean the following:
 Property
 Value
URL
The URl of the organisation service . This is available via the developer          Resources area in the CRM customization section
 domain
 The Domain of where the CRM instance resides. not needed if connecting online. 
 username
the admin username
 Password
the admin password
 Namespace
The namespace for the generated code. Default namespace is the global namespace
 Servicecontextname
The name of the generated organization service context class. If no value is supplied, 
no service context is created.

A file called Xrm.cs will be generated and placed in the  \SDK\Bin folder with a namespace ArtsCouncil.Xrm
Open Visual studio and create a new Project called ArtsCouncil.Xrm. Add the Xrm.cs as a class and delete the default class. Make sure the library .net framework is .net 4
Sign the assembly if its to be used by Plugins 

Add a reference to following dlls. these are in the same bin folder \SDK\Bin
·         Microsoft.Xrm.Sdk.dll
·         Microsoft.Xrm.Portal.dll
·         Microsoft.Xrm.Client.dll
Add the following references from the GAC(.net tab)
·         System.Runtime.Serialization.dll
·         System.Data.Services.dll
·         System.Data.Services.Client.dll

Build. You now have an Early Bound Types Library. The XRM.cs class can overwritten as new customizations get added.

An Example of an on-premise Instance
CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,Microsoft.Xrm.Client.CodeGeneration" /url:http://vs-vm-env/Test/XRMServices/2011/Organization.svc /domain:vsvirtual /username:administrator /password:######## /out:"C:\Xrm.cs" /namespace:VS.PRTB.CRM.DataModel /generateActions

OptionSets

The SDK includes an extension to the CrmSvcUtil to generate OptionSet enumerations. Previously, the tool only generated enums for the StateCode attributes, leaving it as a manual task to create your own enums for any OptionSet values you needed.

Using the extension:

Using Visual Studio, compile the project found at:
sdk\samplecode\cs\crmsvcutilextensions\generatepicklistenums
Edit the 'generateoptionsets.bat' file in the bin\Debug folder, replacing the /url: parameter with the url of your own CRM server.
Double click the 'generateoptionsets.bat', and wait…
You'll see an 'OptionSets.cs' file created in the Debug folder.

You simply need to include this file in any of your projects and use when setting OptionSet values, being sure to cast as (int).

No comments:

Post a Comment