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 :
Microsoft Dynamics CRM (Archived)

CRM : trouble with OrganizationWebProxyClient object always null

(0) ShareShare
ReportReport
Posted on by

Hello guys,

We are using "Microsoft.Xrm.Tooling.Connector" to connect a custom ticketing portal to CRM. Below is the code used to connect. 

The IOrganizationService object is always null. 

string CrmUrl = System.Configuration.ConfigurationManager.AppSettings["CrmServerUrl"];
string CrmOrgname = System.Configuration.ConfigurationManager.AppSettings["CrmOrgName"];
string CrmUserName = System.Configuration.ConfigurationManager.AppSettings["CrmUsername"];
string CrmPassWord = System.Configuration.ConfigurationManager.AppSettings["CrmPassword"];
string sDomain = System.Configuration.ConfigurationManager.AppSettings["CrmDomain"];


CrmServiceClient conn = new CrmServiceClient("Url=" + CrmUrl + "; Username=" + CrmUserName + "; Password=" + CrmPassWord + "; AuthType=Office365");
organizationservice = conn.OrganizationWebProxyClient != null ? conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

Does anyone is aware of a solution to this?

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Hi MatB,

    Please try below code and let me know if you still face issue,

    string CrmUrl = System.Configuration.ConfigurationManager.AppSettings["CrmServerUrl"];

    string CrmOrgname = System.Configuration.ConfigurationManager.AppSettings["CrmOrgName"];

    string CrmUserName = System.Configuration.ConfigurationManager.AppSettings["CrmUsername"];

    string CrmPassWord = System.Configuration.ConfigurationManager.AppSettings["CrmPassword"];

    string sDomain = System.Configuration.ConfigurationManager.AppSettings["CrmDomain"];

    ClientCredentials creadentials = new ClientCredentials();

    creadentials.UserName.UserName = CrmUserName;

    creadentials.UserName.Password = CrmPassWord;

    creadentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

    Uri organization = new Uri(CrmUrl);

    Uri Homeuri = null;

    using (OrganizationServiceProxy serviceproxy = new OrganizationServiceProxy(organization, Homeuri, creadentials, null))

    {                  

    service = (IOrganizationService)serviceproxy;

                   }

    If you find it helpful, Please Mark My Answer as Verified.

    Best Regards,

    Shahbaaz

  • Verified answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Also make sure you have set all the value in app config file properly and you are getting all the value when fetching it from app config

  • Community Member Profile Picture
    on at

    Thanks for the quick help shahbaaz indeed the problem came from the value in app config file.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Can you please add below line above line "CrmServiceClient conn = new CrmServiceClient"

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans