I am always getting null value from the IOrganizationService i am using version 9 i using securtiy protocol also below is my code
IOrganizationService service = null;
string contactid = "0";
string crmAddress = ConfigurationManager.AppSettings["ServiceURL"];
string userName = ConfigurationManager.AppSettings["UserName"];
string pwd = ConfigurationManager.AppSettings["Password"];
//M1
//IOrganizationService service;
//ClientCredentials clientCredentials = new ClientCredentials();
//clientCredentials.UserName.UserName = "svc_crm@investmauritius.com";
////clientCredentials.UserName.Password = "CRM@EDB*2018";
//clientCredentials.UserName.Password = "CRM@EDB*2020";
//// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//// Get the URL from CRM, Navigate to Settings -> Customizations -> Developer Resources
//// Copy and Paste Organization Service Endpoint Address URL
//service = (IOrganizationService)new OrganizationServiceProxy(new Uri(@"">edbmauritius1.crm4.dynamics.com"), null, clientCredentials, null);
//M2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var connectionString = @"AuthType = Office365; Url = " + crmAddress + ";Username=" + userName + ";Password=" + pwd;
CrmServiceClient conn = new CrmServiceClient(connectionString);
//IOrganizationService service;
service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;