Error while retrieving records from Microsoft Dynamics CRM

Viewed 28

I'm getting below error while retrieving records from account table in Dynamics CRM. Error message is in the screenshot below.

enter image description here

Could you please guide me what I'm doing wrong here.

Strange thing is that it is working in a console app. Hence I'm assuming the credentials are correct. But this is not working in SSIS Script Task. I'm a Data Engineer and doesn't have much experience in C#. One more story: This was previously working on other server and that server is decommissioned now. We've got a new server. The moment I executed he code on new server it gave me an error that the assembly was missing. I added the Microsoft.Xrm.Tooling.Connector.dll in GAC and now it is giving this error.

1 Answers

Probably the passed credentials are not valid.

Use the CrmServiceClient.IsReady property to find out if a working connection has been established. If not, property LastCrmError should give you a clue about what went wrong. Property LastCrmException may also be useful.

var client = new CrmServiceClient(connectionString);

if (!client.IsReady)
{
    Console.WriteLine("Failed on first attempt. " + client.LastCrmError);

    // Try again, but now with login prompt. (LoginPrompt=Always)
    ...
Related