locked
Why does CrmServiceClient return null sometimes? RRS feed

  • Question

  • Hi all,

    I'm just trying to understand this behaviour... I'm getting a crm service connection to Dynamics 365. This works 90% of the time. But every now and then it returns null.

    var client = new CrmServiceClient("Url=" + CRMURL + "; Username=" + CRMUser + "; Password=" + CRMPassword + ";AuthType=Office365");

    I noticed it attempts connection, takes a long time at that line, then just continues on without error, but when I look at

    client.OrganizationServiceProxy
    it's null.

    The code ofcourse needs to catch this and retry or decide at some point that it's truly down.

    Anyone else seen this and can it be explained? Is there a way to identify more detail about the underlying cause?

    Thanks

    Friday, April 7, 2017 2:46 AM

All replies

  • This is how it works. It doesn't throw an exception if the connection fails; instead use the LastCrmError or LastCrmException properties

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, April 7, 2017 11:09 AM
    Moderator
  • Thanks.

    I've viewed the LastCrmException and Error values and they also just show something like "the connection object is null". Nothing useful at all as your must check for null in the code anyway.

    So it's not returning anything useful and there is no explanation as to why sometimes it returns null.

    Wednesday, April 26, 2017 2:29 AM