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):
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.
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.
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.
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
After trying multiple things pointed out in other psots I ended up creating a new project and it seems to work in there..
One big help was that in your config connection URL you dont use your company name but the unique ID of your company :
Not :
connectionString="Url=https://hulten.crm4.dynamics.com; Username=nicolas@xxxx.com; Password=xxxx; authtype=Office365"
But :
connectionString="Url=https://uniqueID.crm4.dynamics.com; Username=nicolas@xxxx.com; Password=xxxx; authtype=Office365"
Unique ID is found in developer resources in your dynamics environment.
My bad I am already using 9.0.0.7 (the 2 was a typo)
the latest nuget packages are 9.0.0.7
make sure your connection string contains AuthType and not authtype as you posted, also https is missing from your url.
You can also try with a new c# console application (4.6.2) and just using
string myConnectionString = "AuthType='Office365'; Url='hulten.crm4.dynamics.com'; Username='nicolas@xxxx.com'; Password='xxxx';"; CrmServiceClient service = new CrmServiceClient(myConnectionString); WhoAmIResponse whoAmIResponse = (WhoAmIResponse)service.Execute(new WhoAmIRequest()); Console.WriteLine(whoAmIResponse.UserId.ToString());
Hello,
Check LastCrmError and/or LastCrmException properties of CrmServiceClient instance you instantiate.
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6