In this blog we will learn, how to use CrmSvcUtil tool in Visual Studio. Here are the steps.
- In Visual Studio, create a new “Class Library” project as shown in the following screen shot
- Delete the class file “class1.cs” created by the Visual Studio.
- Add the following files to the project from SDK\Bin folder of CRM SDK.
- CrmSvcUtil.exe
- Microsoft.Crm.Sdk.Proxy.dll
- Microsoft.Xrm.Sdk.dll
- Add an application configuration file to the project and name it “CrmSvcUtil.exe.config”. This file will contain all the parameters we can pass to “CrmSvcUtil.exe”. The solution explorer will look like a following screen.
- Here is a list of all the parameters we can use with CrmSvcUtil.
- Add the following keys to CrmSvcUtil.exe.config file.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="url" value="https://cdc.crm5.dynamics.com/XRMServices/2011/Organization.svc"/> <add key="o" value="CrmProxy.cs"/> <add key="u" value="username@live.com"/> <add key="p" value="password"/> <add key="servicecontextname" value="XrmContext"/> </appSettings> </configuration>
- Now the interesting part, right click on project node and press properties.
- It will pop up a following dialog box. Click on the “Debug” tab
- Select “Start external program” and choose the CrmSvcUtil.exe, we added in step 3.
- Now choose the “Working directory” where you want the output file to go.
- Debug the code and it will come up with following screen.
- You can check the “Output Window” of Visual Studio for the result. If everything goes smoothly, it will create “CrmProxy.cs” file in the folder selected in “Working directory” in step 14.
- Include the “CrmProxy.cs” file into the project.
- Check the CrmProxy.cs, it will have all the crm entities classes and "XrmContext".
Tips
- You can add, remove and edit keys in CrmSvcUtil.exe.config to pass parameters to code generator tool.
- Try accessing the CRM through the browser before debugging, if you are working with CRM Online.
- You can add this project to any of your crm solution. Change the "Working directory" of the project to generate the CrmProxy file in a desired folder.
I have to design a report using fetchxml, it should contain two parameters, showing user names (manager) repectively. I want that as soon as I select user from first drop down(manager), users under the selected manager should appear in the list..
ReplyDeleteAny idea???
Running the project opens a command window which closes when complete. The output window says the program exited with error code 2. Where does the output go?
ReplyDelete