【发布时间】:2019-09-13 05:02:46
【问题描述】:
我创建了一个 Azure 函数,该函数通过 Dynamics 365 中的 webhook 调用。读取远程上下文对象的简单方案确实有效;但是,更复杂的场景会引发错误。尝试使用 CrmServiceClient (Microsoft.Xrm.Tooling.Connector) 获取 Dynamics 服务对象的实例,但是当此行运行 CrmServiceClient client = new CrmServiceClient(crmConnectionString) 时会引发错误:
“无法从程序集 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.14.2.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 中加载类型 'Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior'” em>
我检查了 Azure 中 bin 目录中的 DLL,Microsoft.IdentityModel.Clients.ActiveDirectory 的版本是 2.22。
另外,我检查了 Azure 中的 xxx.deps.json 文件,它显示的版本相同:
"Microsoft.IdentityModel.Clients.ActiveDirectory/2.22.0.0": {
"runtime": {
"Microsoft.IdentityModel.Clients.ActiveDirectory.dll": {
"assemblyVersion": "2.22.0.0",
"fileVersion": "2.22.30211.1727"
}
}
我已经为提到的 DLL 搜索了 3.14.2.11 版本,但找不到它。所以我想知道为什么 Azure 会加载那个版本?
根据其他一些帖子的建议,我在我的函数文件夹下添加了一个文件 -function.proj- 以降级 Azure 加载的那个 DLL 的版本,这是内容:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="2.22.0" />
</ItemGroup>
</Project>
不幸的是,它并没有改变结果。有没有人遇到过同样的问题?
【问题讨论】:
标签: c# azure-functions webhooks dynamics-365