I have a Visual Studio 2017 solution that contains a .Net Core 2.0 console application. I need to access the API of an on-premises CRM 2013 system from the console application, so I created a .Net 4.0 class library in the same solution. In the class library I used Nuget to download Microsoft.CrmSdk.CoreAssemblies, which installed references to Microsoft.Xrm.Sdk and Microsoft.Crm.Sdk.Proxy. I added FetchXml-based data access code to the class library, referenced the class library project from the console application, and rebuilt the solution without errors.
But when I run the console application, I get the following run-time exception whenever the console application instantiates an object from the class library that contains a using statement for Microsoft.Xrm.Sdk:
Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I confirmed that the Microsoft.Xrm.Sdk.dll file is being copied to the bin sub-folder from which the console application is executing.
I’ve tried using different versions of Microsoft.CrmSdk.CoreAssemblies from 6.0.4 to 9.0.2.3, and I’ve tried those versions in combination with .Net 4.0, .Net 4.5, and .Net 4.5.2 versions of the class library, but I always get the same exception message.
Any suggestions about how I can access a CRM 2013 Api from a .Net Core 2.0 console application?