Applying OrganizationServiceProxy when connecting to CRM Dynamics On-line

user1675891 picture user1675891 · Sep 20, 2012 · Viewed 7.8k times · Source

I'm connecting successfully to on-premise server using the organization service by this code.

using (OrganizationServiceProxy proxy = new OrganizationServiceProxy(
  Organization, 
  HomeRealm, 
  CredentialsForClient, 
  CredentialsForDevice)) { ... }

Organization is our server plus the suffix OrgName/XRMServices/2011/Organization.svc. CredentialsForClient is my log-in (or my live ID when going for on-line). HomeRealm and CredentialsForDevice are set to null.

This appears to work perfectly for on-premise version but when I go on-line, I get an error. I can create the proxy variable but when I attempt to execute the code below, the exception tells me that I can't have a null value as an end point. This is hardly telling me anything, due to my ignorance.

EntityCollection entityCollection = proxy.RetrieveMultiple(fetchExpression);

Of course I'm using a different Organization when going on-line. I copied the string from the settings of our on-line version of CRM Dynamics (just as I did for the on-premise version). How can I tackle this problem?

Answer

Jason Lattimer picture Jason Lattimer · Sep 20, 2012

You might want to download the latest version of the SDK and look at the example: Simplified Connection to Microsoft Dynamics CRM. Connection strings differ between on premise and online.

[<add name="Server=CRM Online, organization=YourOrg, user=YourUserName"
         connectionString="Url=https://YourOrg.crm.dynamics.com; [email protected]; Password=YourPassword"/>][2]