Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

IOrganizationService is returning NULL

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:
  • Verified answer
    Santosh341 Profile Picture
    Santosh341 30 on at
    RE: IOrganizationService is returning NULL

    Hi Mayur.. thanks it works perfectly !!!

  • Santosh341 Profile Picture
    Santosh341 30 on at
    RE: IOrganizationService is returning NULL

    Hi Ben,

    Thanks for reply but the O365 Password has not expired.

  • Verified answer
    imayur Profile Picture
    imayur 630 on at
    RE: IOrganizationService is returning NULL

    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;


  • Suggested answer
    Johnny Gong Profile Picture
    Johnny Gong 6,482 on at
    RE: IOrganizationService is returning NULL

    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

  • Suggested answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: IOrganizationService is returning NULL

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

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans