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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer Service forum

IOrganizationService is returning NULL

(0) ShareShare
ReportReport
Posted on by 30

I have used Microsoft.Xrm.Tooling.Connector to connect D365. The code was working fine till yesterday evening all of sudden it get stop and the root cause is IOrganizationService is returning NULL  can anyone help me on this issue below is the code -

 CrmServiceClient crmConn = new CrmServiceClient(@"AuthType=Office365;Username=**********; Password=***********;Url=https://*********.crm8.dynamics.com");

IOrganizationService crmService = crmConn.OrganizationServiceProxy;
Guid userid = ((WhoAmIResponse)crmService.Execute(new WhoAmIRequest())).UserId;

Categories:
I have the same question (0)
  • Suggested answer
    Ben Thompson Profile Picture
    6,350 on at

    Office 365 passwords may expire and need to be updated. Has the password expired?

  • Suggested answer
    Johnny Gong Profile Picture
    6,482 Moderator on at

    Hi,

    If the code is working fine and suddenly get stopped, I don't think it's due to the code issue.

    Have you tried to login your Instance normally or is there any update on your org? If your org has been updated to V9.0. You need to set Security as TLS12

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    Related cases could be referred by following linkage:

    https://community.dynamics.com/crm/f/117/t/266617

    https://arunpotti.wordpress.com/2018/02/03/step-by-step-to-connect-dynamics-365-crm-online-v9-x-using-c-console-application/ 

    You could also check the follow similar cases to check your coding while I don't think they may be the root cause of your issue.

    https://community.dynamics.com/crm/f/117/t/202298 

    [View:https://community.dynamics.com/crm/f/117/t/226109:750:50]

    Best Regards

    Johnny Gong

  • Verified answer
    imayur Profile Picture
    630 on at

    Hi,

    Please use below snippet for Organization service connection

    for Dynanics CRM version 9 above
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //TLS1.2 is required for v9 and above
               CrmServiceClient con = new CrmServiceClient("connectionString");
               var service = (IOrganizationService)con.OrganizationWebProxyClient != null ?
                                   (IOrganizationService)con.OrganizationWebProxyClient : (IOrganizationService)con.OrganizationServiceProxy;
    for version <8 and >9
               CrmServiceClient con = new CrmServiceClient("connectionString");
               var service = (IOrganizationService)con.OrganizationWebProxyClient != null ?
                                   (IOrganizationService)con.OrganizationWebProxyClient : (IOrganizationService)con.OrganizationServiceProxy;


  • Santosh341 Profile Picture
    30 on at

    Hi Ben,

    Thanks for reply but the O365 Password has not expired.

  • Verified answer
    Santosh341 Profile Picture
    30 on at

    Hi Mayur.. thanks it works perfectly !!!

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans