简体   繁体   中英

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;Username=user@azureresulticks.onmicrosoft.com;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.

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM