I want to create a VS 2010 C# console application that connects to two (or more) different CRM 2011 servicecontexts / tenants. I want to be able to update data in one with data from the other.
If I create two different early bound classes with crmsvcutil I get a compiler error: “Duplicate ‘Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute’ attribute”
If I concatenate the two files, it compiles but then I get a runtime error: “A proxy type with the name account has been defined by multiple types”.
How can this be accomplished?
Create a separate library project for each set of early bound classes and place one of the crmsvcutil files in each library (add assembly references as required). Now, on the console app, add references to the libraries.
Let’s say I created two library projects that compile to Proxy1.dll and Proxy2.dll. The root namespaces for each library are Proxy1 and Proxy2. In the ConsoleApp.exe, I add the two references and the following: