0

Using the latest SDK for Dynamics CRM, I am attempting to create a new CRMServiceClient([ConnectionString]). I try to do anything with it including a WHOAMI request, and I get Unable to Login to Dynamics OrganizationServiceProxy is null. When I run fiddler, nothing is even attempting to communicate to the server to attempt a login. I am unsure what is wrong, as I would have thought newing up a CRMServiceClient would have tried to connect since OrganizationServiceProxy is a child object of CRMServiceClient. Anyone have any ideas how to approach solving this?

var temp = new CrmServiceClient(ConfigurationManager.ConnectionStrings["con‌​n"].ConnectionString‌​); 
<add name="conn" connectionString="AuthType=AD; Url=Url/DEVCRM; Username=User; Password=pass;"/> 
Daryl
  • 18,592
  • 9
  • 78
  • 145
James W
  • 11
  • 1
  • 2
    Please share your code and exception details. With the information you provided it's hard to tell what's wrong. – Henk van Boeijen Jul 14 '17 at 15:45
  • Most likely your connection string is bad, but with the information you provided it's not possible to help you – Pawel Gradecki Jul 14 '17 at 16:01
  • var temp = new CrmServiceClient(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); So when I run the 1 line of code, the OrganizationServiceProxy is null. the connection string is above as well. Changed URL, Username and password to hide true information. – James W Jul 14 '17 at 16:33

3 Answers3

1

Please note that CrmServiceClient has a boolean property called IsReady, which is a good way to check if it's in a proper state.

And for reference, here are example connection strings for the various environment types:

CRM 2016 and Dynamics 365 online:

<add name="dev26" connectionString="Url=https://dev26.crm.dynamics.com; Username=user@dev26.onmicrosoft.com; Password=Pass; AuthType=Office365" />

On-premise with integrated security:

<add name="prod" connectionString="Url=http://myserver/AdventureWorksCycle;"/>

On-premise with credentials:

<add name="prod" connectionString="Url=http://myserver/AdventureWorksCycle; Domain=mydomain; Username=administrator; Password=password; AuthType=AD;"/>

On-premise IFD before CRM 2016:

<add name="prod" connectionString="Url=https://contoso.litware.com; Username=someone@litware.com; Password=password; AuthType=IFD;"/>

On-premise IFD for CRM 2016 and later (v8.0+)

<add name="prod" connectionString="ServiceUri=https://contoso.litware.com/contoso; Domain=contoso; Username=contoso\administrator; Password=password; AuthType=IFD; LoginPrompt=Never;" />
Aron
  • 3,877
  • 3
  • 14
  • 21
0

Based on your connectionstring I would suggest you to add domain to it. That should resolve your issue. Check following example:

Named account using on-premises authentication

<add name="MyCRMServer"connectionString="AuthType=AD;Url=http://contoso:8080/Test;Domain=CONTOSO; Username=jsmith; Password=passcode" />

You can find more information in following article - https://msdn.microsoft.com/en-us/library/mt608573.aspx

Andrew Butenko
  • 5,048
  • 1
  • 14
  • 13
  • I have also used this format: AuthType=AD;Url=https://[server]/DEVCRM;Domain=[Domain];Username=[user(no domain)];Password=[pass]" I still get a null OrganizationServiceProxy. I can login to the dynamics instance at the URL with the username and password just find. – James W Jul 14 '17 at 17:28
  • Does the CrmServiceClient connect to CRM in the constructor? If so, shouldn't Fiddler see it? – Daryl Jul 14 '17 at 18:12
0

I have found that .net 4.6.2 doesn't play nicely with the CRM SDK, if you are running that version of .net upgrade or downgrade the framework installed on your computer.

Updating to .net 4.6.2 from .net 4.5.2 causing Object Reference Exception on ExecuteCore method within xrm sdk

If that isn't the cause, enable tracing to get more detailed error messages, see following article for details: https://msdn.microsoft.com/en-au/library/dn689064.aspx