Recently my (outdated) connection to my Dynamics online environment (Microsoft Dynamics 365 version1612 (9.0.0.3172) (DB 9.0.0.3172) online) stopped working for some reason.
OLD connection:
Uri serviceUri = new Uri(SoapOrgServiceUri); OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null)
I was advised to use a newer connection found on the following links:
msdn.microsoft.com/.../jj602970.aspx
https://msdn.microsoft.com/en-us/library/dn688177.aspx
So I tried to implement one of these connections, but after multiple tries and using different connection setups, they all seem to be returning False on the IsReady state of the CrmService client. I am probably doing something wrong but I can't figure out what.
The code used to connect to my CRM (tried more but deleted most of those tries):
Example 1:
String connectionString = GetServiceConfiguration(); CrmServiceClient m_CrmServiceClient = new CrmServiceClient(connectionString); private static String GetServiceConfiguration() { // Get available connection strings from app.config. int count = ConfigurationManager.ConnectionStrings.Count; // Create a filter list of connection strings so that we have a list of valid // connection strings for Microsoft Dynamics CRM only. List<KeyValuePair<String, String>> filteredConnectionStrings = new List<KeyValuePair<String, String>>(); for (int a = 0; a < count; a++) { if (isValidConnectionString(ConfigurationManager.ConnectionStrings[a].ConnectionString)) filteredConnectionStrings.Add (new KeyValuePair<string, string> (ConfigurationManager.ConnectionStrings[a].Name, ConfigurationManager.ConnectionStrings[a].ConnectionString)); } // No valid connections strings found. Write out and error message. if (filteredConnectionStrings.Count == 0) { return null; } // If one valid connection string is found, use that. if (filteredConnectionStrings.Count == 1) { return filteredConnectionStrings[0].Value; } // If more than one valid connection string is found, then return null. if (filteredConnectionStrings.Count > 1) { return null; } return null; }
The connection string used :
<add name="Server=CRM Online, organization=hulten, user=nicolas" connectionString="Url=hulten.crm4.dynamics.com; Username=nicolas@xxxx.com; Password=xxxx; authtype=Office365" />
This returns the following error on debugging (which can be ignored right?):
And it returns false on the IsReady property of the CrmServiceClient.
Example2:
CrmServiceClient crmSvc = new CrmServiceClient("nicolas@xxxx.com", CrmServiceClient.MakeSecureString("xxxx"), "Europe", "hulten", useUniqueInstance:false, useSsl:false, isOffice365:true);
Same issue here, also return false on IsReady.
Goal of application
The goal I want to achieve is simple, use a function in my web application (C#, .Net 4.6.2) which inserts data into my CRM environment.
Details of my environment / additional information
Dynamics version: Microsoft Dynamics 365 version1612 (9.0.0.3172) (DB 9.0.0.3172) online
C# application: Web, targeting framework = .Net 4.6.2
Xrm SDK tool / Tooling / Crm SDK Proxy versions : All updated to 9.0.0.2 (latest)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Used before connecting (suggested as fix in several posts).
My credentials used are fine (I can login into dynamics) and I have admin rights.
*This post is locked for comments