Step 1: Open Visual Studio -> Create a New Project with Console App (.NET Framework)
Step 2: Fill in all the details as shown and Click Create
Step 4: Open the class file and add the below code and click on save
using Microsoft.Xrm.Tooling.Connector;
using Microsoft.Xrm.Sdk;
namespace ConsoleAppProjects
{
public class D365ConnectionService
{
public static IOrganizationService service;
public static IOrganizationService ConnectionService()
{
try
{
var connectionString = @"AuthType = Office365; Url = https://orgd***.crm8.dynamics.com/;Username=Amresh@CRM***.onmicrosoft.com;Password=D**@1234";
CrmServiceClient conn = new CrmServiceClient(connectionString);
service = conn.OrganizationWebProxyClient ?? (IOrganizationService)conn.OrganizationServiceProxy;
if (service != null)
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
return service;
}
}
That's all...
{
Console.WriteLine("Connected Successfully....");
//Executing YOUR CRM OPERATIONS.
}
else
{
Console.WriteLine("Connection failed....");
}
}catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
return service;
}
}
}
Step 5: Start and test.
That's all...
Thank you!!!