Microsoft Dynamics 365 SDK核心程序集.NET Core移植错误 [英] Microsoft Dynamics 365 SDK Core Assemblies .NET Core Porting Error

查看:338
本文介绍了Microsoft Dynamics 365 SDK核心程序集.NET Core移植错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试在中使用 Microsoft Dynamics 365 SDK核心程序时. NET Core 2.0项目,在运行时仅通过using Microsoft.Xrm.Sdk会发生以下错误:

When trying to use Microsoft Dynamics 365 SDK Core Assemblies in a .NET Core 2.0 project, the following error occurs at runtime simply by using Microsoft.Xrm.Sdk:

TypeLoadException:无法加载类型 来自的"System.ServiceModel.Description.MetadataConversionError" 程序集'System.ServiceModel,版本= 4.0.0.0,区域性=中性, PublicKeyToken = b77a5c561934e089'.

TypeLoadException: Could not load type 'System.ServiceModel.Description.MetadataConversionError' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

看起来核心程序集(Microsoft.Xrm.Sdk.Client)可能根本不兼容〜net4x.

It looks like the Core Assemblies (Microsoft.Xrm.Sdk.Client) may simply not be compatible with anything other than ~net4x.

在目标netcoreapp2.0的上下文中,是否有任何明显的方法来解决此错误或加载Microsoft.Xrm.Sdk所需的WCF System.ServiceModel类/接口?是否可以使用 Microsoft.Windows.Compatibility 来弥合差距?看起来像Microsoft.Windows.Compatibility包文档表示 Windows Communication Foundation(WCF)类/界面可用".如何使用兼容性包加载System.ServiceModel.Description?

Is there any obvious way to get around this error or load the WCF System.ServiceModel class/interfaces needed by Microsoft.Xrm.Sdk in the context of target netcoreapp2.0? Is it possible to use Microsoft.Windows.Compatibility to bridge the gap? It looks like the Microsoft.Windows.Compatibility pack documentation indicates Windows Communication Foundation (WCF) classes/interfaces are "available". How can I use the compatibility pack to perhaps load System.ServiceModel.Description?

感谢您提供的任何帮助!

Thank you for any help you can provide!

推荐答案

根据github上的多次讨论,我尝试了所有可能的方法,并且可以说SDK,ServiceModel等与.net核心不兼容,也永远不会兼容.但是,我能够做到这一点:

I tried all possible things and can say that SDK, ServiceModel etc are not compatible with .net core and never will be, according to multiple discussions on github. However, i was able to do this:

  • 使用XrmToolBox和crmsvcutil.exe生成模型(可选)
  • 将它们放在netstandard2项目中
  • 从nuget引用XRM SDK
  • SDK在.net核心下工作,部分将LINQ查询和原始QueryExpression转换为OrganizationRequest的子类
  • 编写自定义IOrganizationService,该服务将序列化OrganizationRequests并将其发送到其他应用
  • 其他应用程序是.net核心Web api,它引用了该项目和XRM SDK,但在Windows的完整框架上运行,并执行实际请求,序列化响应并将其发回.
  • Use XrmToolBox and crmsvcutil.exe to generate models (optional)
  • place them in netstandard2 project
  • reference XRM SDK from nuget
  • SDK works under .net core in part where LINQ queries and raw QueryExpressions are translated to subclasses of OrganizationRequest
  • write custom IOrganizationService which serializes OrganizationRequests and sends them to some other app
  • Other app is .net core web api which references that project and XRM SDK, but runs on full framework on windows and executes actual requests, serializes responses and sends them back.

重要 我发现由于各种原因,SDK 2016在Linux上的.net core中无法可靠运行,并于2011年停止(nuget包为Microsoft.Xrm.Sdk.2011).除非出现以下情况,否则它可以正常工作:您执行context.AddObject并传递没有ID的实体 . SDK依赖于p/调用本机Windows库来创建连续的UUID并在Linux上崩溃.您可以通过在调用.AddObject()之前设置ID来解决此问题.

IMPORTANT I found out that SDK 2016 doesn't work reliably in .net core on linux due to various reasons, and stopped at 2011 (nuget package is Microsoft.Xrm.Sdk.2011). It works fine except in one case: whe you do context.AddObject and pass an Entity with no ID. SDK relies on p/invoking native Windows library to create sequential UUID and crashes on Linux. You can overcome this by setting ID prior to calling .AddObject().

这篇关于Microsoft Dynamics 365 SDK核心程序集.NET Core移植错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆