Connecting to CRM 2013/2015/2016 and Dynamics 365 in C#

Dynamics CRM 2013/2015/2016/Dynamics 365

In our day to day tasks we often need to connect CRM in C# either in a plugin, a console application or a service. In this article I will present different ways to do that.

Method 1
Use this method to connect when you want to use your connection info directly in code. This method can be used for CRM 2013/2015/2016.

Method 2
Use this method to connect with CRM 2013/2015/2016 when your connection info is in config file.

Config settings will be like this

Method 3
Use this method to connect with CRM 2013/2015/2016 when your connection string is in config file.

Config settings will be like this

Method 4
User this method to connect with Dynamics 365 On-Premise

//– Note: In order to use CrmServiceClient class, you need to use namespace “Microsoft.Xrm.Tooling.Connector” which exists in Dynamics 365 Dll named “Microsoft.Xrm.Tooling.Dll”

Config settings will be like this

Method 5

View original post 21 more words