Hi Pawel,
Thank you for your feedback.
As I told you : I’m a beginner. And there a lot of things that I need to understand, else if obvious for you.
I’ll do my best to explain my actions, step by step : I need to identify where I’m wrong.
Visual Studio 2017 Community :
1. New Project > Class Library (.NET Framework) > Name : Proxy1
Tools > NuGet Manager > Install Microsoft.CrmSdk.CoreAssemblies v8.2.0.2 & Install Microsoft.CrmSdk.Extensions v7.1.0.1 (Microsoft.CrmSdk.Deployment v7.1.0 included)
Add Existing Element : XrmSource.cs (generated with CrmSvcUtil)
Build solution
2. Proxy2 : Idem #1
3. New Project > Console Application (.NET Framework) > Name : MyConsoleApp
Tools > NuGet Manager > Install Microsoft.CrmSdk.CoreAssemblies v8.2.0.2 & Install Microsoft.CrmSdk.Extensions v7.1.0.1 (Microsoft.CrmSdk.Deployment v7.1.0 included)
Copy/Paste StackOverflow Code : https://stackoverflow.com/questions/10548683/how-to-create-one-net-solution-for-crm-2011-that-connects-to-two-different-serv
Add :
- using Microsoft.Xrm.Sdk.Client;
- using System.Reflection;
References > Add a reference > Browse ..\Proxy1\Proxy1\bin\Debug\Proxy1.dll
References > Add a reference > Browse ..\Proxy1\Proxy1\bin\Debug\Proxy2.dll
At this time, I have the following code
using System;
using Microsoft.Xrm.Sdk.Client;
using System.Reflection;
namespace MyConsoleApp
{
class Program
{
static void Main(string[] args)
{
var url1 = new Uri("mycrmdev.crm4.dynamics.com/.../Organization.svc");
var proxy1 = new OrganizationServiceProxy(url1, null, null, null);
proxy1.EnableProxyTypes(Assembly.Load("Proxy1")); // Proxy1.dll
var url2 = new Uri("mycrmprod.crm4.dynamics.com/.../Organization.svc");
var proxy2 = new OrganizationServiceProxy(url2, null, null, null);
proxy2.EnableProxyTypes(Assembly.Load("Proxy2")); // Proxy2.dll
using (var context1 = new Proxy1.XrmSourceServiceContext(proxy1))
using (var context2 = new Proxy2.XrmTargetServiceContext(proxy2))
{
var accounts1 = context1.AccountSet;
var accounts2 = context2.AccountSet;
foreach (var account in accounts1) Console.WriteLine("1: {0}: {1}", account.GetType(), account.Id);
foreach (var account in accounts2) Console.WriteLine("2: {0}: {1}", account.GetType(), account.Id);
}
}
}
}
And I get errors here :
using (var context1 = new Proxy1.Proxy1ServiceContext(proxy1))
using (var context2 = new Proxy2.Proxy2ServiceContext(proxy2))
I don't know what to do at this moment :(