Dynamics crm 无法加载文件或程序集';Microsoft.IdentityModel.Clients.ActiveDirectory';在CRM插件中

Dynamics crm 无法加载文件或程序集';Microsoft.IdentityModel.Clients.ActiveDirectory';在CRM插件中,dynamics-crm,microsoft-dynamics,dynamics-crm-online,Dynamics Crm,Microsoft Dynamics,Dynamics Crm Online,我正在开发一个使用ADAL nuget包的插件。由于缺少Microsoft.IdentityModel.Clients.ActiveDirectory dll,我的插件程序集在执行时引发异常。程序集正在引用并在合并的dll中正确合并,这是我在ILSpy工具中看到的: 以下是我的插件程序集中的引用列表: 有没有办法解决这个问题 在我尝试使用ILMerge和ILRepack使用多种工具合并DLL后,我遇到了同样的问题。我如何找到Clients.ActiveDirectory依赖项,我认为这是错误的

我正在开发一个使用ADAL nuget包的插件。由于缺少Microsoft.IdentityModel.Clients.ActiveDirectory dll,我的插件程序集在执行时引发异常。程序集正在引用并在合并的dll中正确合并,这是我在ILSpy工具中看到的:

以下是我的插件程序集中的引用列表:

有没有办法解决这个问题

在我尝试使用ILMerge和ILRepack使用多种工具合并DLL后,我遇到了同样的问题。我如何找到Clients.ActiveDirectory依赖项,我认为这是错误的根本原因?

这个插件被部署到一个CRM在线实例中,所以我不能像在本地那样将DLL添加到GAC中

以下是我在执行使用ADAL nuget软件包的插件时从插件注册工具中看到的确切错误消息:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: **Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=4.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencie**s. The system cannot find the file specified.
Detail: <OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ActivityId>00000000-0000-0000-0000-000000000000</ActivityId>
  <ErrorCode>-2147220970</ErrorCode>
  <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <a:key>CallStack</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">   at Microsoft.Dynamics.PerceptionAnalytics.Plugins.ProvisionFloorPlan.&lt;Execute&gt;d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine&amp; stateMachine)
   at Microsoft.Dynamics.PerceptionAnalytics.Plugins.ProvisionFloorPlan.Execute(IServiceProvider serviceProvider)
   at PluginProfiler.Library.PluginAppDomainProxy.ExecuteCore(Stopwatch watch, ProfilerExecutionReport report, Object instance, Object executionParameter)
   at PluginProfiler.Library.AppDomainProxy.Execute(ProfilerExecutionConfiguration configuration, ProfilerExecutionReport report)</a:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=4.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</Message>
  <Timestamp>2019-01-03T18:30:29.4049324Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil="true" />
  <InnerFault i:nil="true" />
  <OriginalException i:nil="true" />
  <TraceText i:nil="true" />
</OrganizationServiceFault>
未处理的异常:System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault,Microsoft.Xrm.Sdk,Version=9.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35]:**无法加载文件或程序集'Microsoft.IdentityModel.Clients.ActiveDirectory,Version=4.4.2.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35'或其依赖项**s之一。系统找不到指定的文件。
详情:
00000000-0000-0000-0000-000000000000
-2147220970
呼叫栈
在Microsoft.Dynamics.PerceptionAnalytics.Plugins.ProvisionFloorPlan.Executed\uu 0.MoveNext()中
在System.Runtime.CompilerServices.AsynchvoidMethodBuilder.Start[TStateMachine](TStateMachine&;stateMachine)
在Microsoft.Dynamics.PerceptionAnalytics.Plugins.ProvisionFloorPlan.Execute(IServiceProvider服务提供商)上
位于PluginProfiler.Library.PluginAppDomainProxy.ExecuteCore(秒表、ProfileExecutionReport、对象实例、对象执行参数)
在PluginProfiler.Library.AppDomainProxy.Execute(ProfileExecutionConfiguration配置,ProfileExecutionReport报告)
无法加载文件或程序集“Microsoft.IdentityModel.Clients.ActiveDirectory,版本=4.4.2.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件。
2019-01-03T18:30:29.4049324Z
假的
  • 您可以检查是否从GAC添加了此参考。
    如果是,则可能需要将jt设置为复制到输出目录。 您可以检查文件是否存在于执行目录中

  • 另一个原因可能是您有多个项目引用此adal。每个都指不同的版本。 它们都设置为复制到输出目录。但是最终的构建输出没有插件所期望的版本


  • 您必须将所有必需的dll合并到单个插件dll中,然后注册它。您可以使用ILMERGE来执行此操作

    甚至您也可以使用构建后Powershell命令脚本来自动执行此操作。

    根据,不支持在插件中使用ILMerge

    您正在尝试使用ADAL访问CRM还是其他Azure系统?如果您正在访问CRM,则可以使用本机IOrganizationService


    如果你瞄准另一个系统,你可能想考虑使用一个来逃避沙盒并在CRM之外运行你的逻辑。< /P> POST精确异常,这样确切的根本原因可以发布精确的错误。我已验证目标输出文件夹和合并dll中的版本是否相同。您无法在GAC中为CRM online添加dll。抱歉,我忽略了它,我的错误。你提到它已经正确地合并了。您可以取消注册并再次注册吗?@Mostafa有时这可能很愚蠢,您的vs构建模式可能处于调试状态,但您可以注册发布文件夹内容,反之亦然。我使用的是调试编译的DLL。如果它与插件执行时您已经可以访问的CRM数据相关,那么在CRM之外运行逻辑就没有意义了。我不是针对上面建议的另一个系统。好的,如果您正在访问CRM,您可以通过,而无需ADAL来做任何您需要的事情。