web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

an unhandled exception of type system.nullreferenceexception occurred in Microsoft.XRM.Tooling.Connector.dll

(0) ShareShare
ReportReport
Posted on by

string crmConnectionString = ConfigurationManager.AppSettings["CRMConnectionString"];
CrmServiceClient service = new CrmServiceClient(crmConnectionString);
WhoAmIResponse whoAmIResponse = (WhoAmIResponse)service.Execute(new WhoAmIRequest());

QueryExpression query_Contacts = new QueryExpression("contact");
query_Contacts.ColumnSet = new ColumnSet("Accountname", "Fullname");
EntityCollection coll_Contacts = service.RetrieveMultiple(query_Contacts);

Can anyone tell me why I am getting error : 

an unhandled exception of type system.nullreferenceexception occurred in Microsoft.XRM.Tooling.Connector.dll

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi,

    Could you please debug and see if you are getting the connection in "service" variable.

    Also use before the connection.

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    lastly , please share your "CRMConnectionString".

  • Community Member Profile Picture
    on at

    query_Contacts.ColumnSet = new ColumnSet("parentcustomerid", "fullname");

    Use above line. i don't think there is a field Accountname on contact. Please verify all the fieldnames in columnset are present in crm record and field names in columnset should be in lower case.

  • Community Member Profile Picture
    on at

    <appSettings>

       <add key="CRMConnectionString" value="AuthType='Office365'; Url='https://**************.dynamics.com/'; Username='Za.aa.com'; Password='XX';" />

     </appSettings>

    That was my CRMConnectionString and when I debug it gets stuck at11830.Capture.PNG

    Waiting for your kind response.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi,

    Can you simply use:

    <connectionStrings>

       <add name="MyCRMServer" connectionString="AuthType=AD;Url=http://contoso:8080/Test;" />

    </connectionStrings>

    and code :

    CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["MyCRMServer"].ConnectionString);

  • Community Member Profile Picture
    on at

    I want to see the records of Contact Entity and so I was trying the below code which is now showing error because i dont have service anymore

    QueryExpression query_Contacts = new QueryExpression("contact");

     query_Contacts.ColumnSet = new ColumnSet(true);

                EntityCollection coll_Contacts = service.RetrieveMultiple(query_Contacts);

    Can you suggest please

  • gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Take a look below reference code -

    goutamdascrm.wordpress.com/.../connecting-dynamics-365-online-using-console-application-c

  • Community Member Profile Picture
    on at

    I tried to use only these few lines to connect to CRM through windows application but getting error -

    System.ServiceModel.FaultException occured in .exe

    Can anyone please advice

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Suchisuchi,

    Could you please try this SDK sample (Example 2) and see if it works. Notice the check "if (crmSvc != null && crmSvc.IsReady)" and else part to display the message if there is a problem in connection.

    msdn.microsoft.com/.../dn688174.aspx

    Basically you need to isolate and find if there is a problem in connecting to CRM or executing the retrieve multiple for contact. Break your code to just return the WhoAmI response first and see if that works or not.

    Hope this helps.

  • Community Member Profile Picture
    on at

    <Server>", "<Port>", "<OrgName>");

    What are these information, Mine is CRM online, i wont know servername, so not sure how to try that, Ravi

  • Community Member Profile Picture
    on at

    Can anyone please give me one error free code for connecting to CRM through C# Windows form, I tried everything from net. Noways are helping me to connect. It throws so many errors that I got fed up.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans