James W
James W

Reputation: 11

CRMServiceClient does not try to connect to Dynamics CRM

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;"/> 

Upvotes: 0

Views: 2147

Answers (3)

Hadley Pettigrew
Hadley Pettigrew

Reputation: 51

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

Upvotes: 0

Aron
Aron

Reputation: 3935

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; [email protected]; 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; [email protected]; 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;" />

Upvotes: 1

Andrew Butenko
Andrew Butenko

Reputation: 5446

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

Upvotes: 0

Related Questions