locked
What is the proper way to check if the connection succeeded? RRS feed

  • Question

  • We use a CrmConnection in our .NET project to connect to CRM.  It's working fine.  However, we're currently doing a WhoAmIRequest after connecting to verify the connection succeeded.  This feels hacky and it's slow.  Is there a property or method in the CrmConnection class that is designed to tell you if the connection succeeds?  If there is, I haven't found it yet.  I've googled my fingers off and looked at countless CrmConnection examples, but they all seem to just assume the connection was successful.

    Thanks!

    Ray

    Thursday, January 9, 2014 5:39 PM

Answers

  • Hello Ray,

    I believe that WhoAmI message is the easiest way to check connection. I have never thought that it is hacky and slow, so I use it in my integration projects. I believe that there could be other approaches to use it but I believe that this one is the easiest.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Thursday, January 9, 2014 5:51 PM
    Moderator

All replies

  • Hello Ray,

    I believe that WhoAmI message is the easiest way to check connection. I have never thought that it is hacky and slow, so I use it in my integration projects. I believe that there could be other approaches to use it but I believe that this one is the easiest.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Thursday, January 9, 2014 5:51 PM
    Moderator
  • Hi,

    it is slow because is your first request to CRM, if you try with another message the first hit will be slow too.


    My blog: www.crmanswers.net - Rockstar 365 Profile

    Thursday, January 9, 2014 5:55 PM
  • Well, at least I know we're not just missing something.  I know the first request will be slow.  It just seems like you shouldn't have to blindly try a request and catch the exception just to see if the connection succeeded.  It's not critical, it'd just be nice if there was a "Connected" property or something similar that we could check instead.   One of our projects (used internally by our IT staff) has the user input the connection info and we give them a button to test the connection with.  Because it's having to do an actual request, this takes a few seconds, whereas our SQL connection's test button tells the user immediately.

    Oh well, a few seconds isn't terrible.  It's more the try/catch around the request that bothers me.  Either way, CrmConnection is very easy to use and lightyears ahead of the old ways of setting up connections to CRM.

    Thanks for the replies!

    Ray

    Thursday, January 9, 2014 7:22 PM