Search code examples
c#.net-coredynamics-crm

How to create CrmServiceClient instance in .Net Core 3.1?


I tried this code:

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;

var connectionString = @"AuthType = Office365; 
                         Url = https://myorg.api.crm8.dynamics.com/XRMServices/2011/Organization.svc;[email protected];Password=***";

CrmServiceClient conn = new CrmServiceClient(connectionString);

IOrganizationService service;

but I'm getting this error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'

on trying to create the CrmServiceClient instance.

The same piece of code was working in .NET framework versions.

But this time, I have to use .NET Core.


Solution

  • Microsoft.CrmSdk.XrmTooling.CoreAssembly is a NuGet package built on .NET Framework 4.6.2. It is not compatible with .NET Core.

    When connecting with Dynamics 365 CE from a .NET Core project, try package Microsoft.PowerPlatform.Dataverse.Client. It is pretty new and designed for .NET Core and Dynamics 365 Online.

    See also: