How about adding Proxy Types behavior to the connection?

Mar 22, 2013 at 7:43 PM
            SendStepChange("Creating Organization service proxy...");
            var orgProxy = new OrganizationServiceProxy(uri, homeRealmUri, clientCredential, deviceCredential);
            var service = (IOrganizationService)orgProxy;
I'ts not that tough to add 'EnableProxyTypes()' myself but it might be nice if the control automatically enabled that behavior, or had a configuration to enable it instead of modifying the resulting service i n my own code. (so that all my early bound LINQ stuff will work in the utility I'm using this in)

Not a huge deal though - this is terrific!
Ken
Mar 27, 2013 at 10:02 PM
Just for anyone interested in using this with proxy types (early bound classes) I downloaded source and modified ConnectionManager.cs with something like the following:
            SendStepChange("Creating Organization service proxy...");
            var orgProxy = new OrganizationServiceProxy(uri, homeRealmUri, clientCredential, deviceCredential);

            if (EarlyBoundTypesAssembly != null)
            {
                orgProxy.EnableProxyTypes(System.Reflection.Assembly.LoadFile(EarlyBoundTypesAssembly));
            }
            else
            {
                orgProxy.EnableProxyTypes();
            }

            var service = (IOrganizationService)orgProxy;

            TestConnection(service);
Most people will probably be ok with just 'orgProxy.EnableProxyTypes(); - I added the reflection stuff to make it work with a plugin unit test tool I am working on that dynamically can load a custom library of test methods that use early bound types.
Coordinator
Mar 28, 2013 at 8:50 AM
Hi,

Thanks for this example, could you indicates how you initialized the variable/property EarlyBoundTypesAssembly?
May 22, 2013 at 11:25 AM
hi tanguy

the only change needed to enable proxy types is the following:

connectionmanager.cs - the 3rd line below is added to enable the proxy types behavoiur
SendStepChange("Creating Organization service proxy...");
var orgProxy = new OrganizationServiceProxy(uri, homeRealmUri, clientCredential, deviceCredential);                
orgProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
in your app:

to use the proxy types in code, modify the cManager_ConnectionSucceed handler to also initialise an organization service context (_orgContext) as follows:
            // Store connection Organization Service
            this._service = e.OrganizationService;
           this._orgContext = new OrganizationServiceContext(_service);
and then consume it like the following (_orgContext.CreateQuery<Campaign>):
            var _campaigns = from c in _orgContext.CreateQuery<Campaign>()
                             orderby c.Name
                             select new Campaign
                             {
                                 Name = c.Name,
                                 CampaignId = c.CampaignId,
                             };
            foreach (var c in _campaigns)            
hope that helps?
nzregs