0
votes

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;"/> 
3
Please share your code and exception details. With the information you provided it's hard to tell what's wrong.Henk van Boeijen
Most likely your connection string is bad, but with the information you provided it's not possible to help youPawel Gradecki
var temp = new CrmServiceClient(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); <add name="conn" connectionString="AuthType=AD; Url=Url/DEVCRM; Username=User; Password=pass;"/> 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

3 Answers

1
votes

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

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

0
votes

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