AzureAD / microsoft-authentication-library-for-dotnet

Microsoft Authentication Library (MSAL) for .NET
https://aka.ms/msal-net
MIT License
1.36k stars 330 forks source link

[Bug] {"code":"0x80040265","message":"Error in DocumentManagementIntegration: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.61.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionSourceKey":"Plugin/$Microsoft.Crm.Workflow.Services.ProxyCustomActivity","@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepKey":"3abd7e64-8b32-ef11-8e4e-000d3acb86b9" #4822

Open MOHAMMEDFAKHRI opened 3 days ago

MOHAMMEDFAKHRI commented 3 days ago

Library version used

4.61.3

.NET version

4.6.2

Scenario

Visual Studio Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.9.7

ConfidentialClient - PowerApps (AcquireTokenByAuthCode)

Is this a new or an existing app?

This is a new app or experiment

Issue description and reproduction steps

Error uploading file How To Apply Your 100% Discounted Voucher Code .pdf: Can't upload chunk 0 of file How To Apply Your 100% Discounted Voucher Code .pdf: {"error":{"code":"0x80040265","message":"Error in DocumentManagementIntegration: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.61.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionSourceKey":"Plugin/$Microsoft.Crm.Workflow.Services.ProxyCustomActivity","@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepKey":"3abd7e64-8b32-ef11-8e4e-000d3acb86b9","@Microsoft.PowerApps.CDS.ErrorDetails.ApiDepthKey":"1","@Microsoft.PowerApps.CDS.ErrorDetails.ApiActivityIdKey":"0c975f93-6160-4bc0-a323-f635e2880c11","@Microsoft.PowerApps.CDS.ErrorDetails.ApiPluginSolutionNameKey":"System","@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepSolutionNameKey":"System","@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionCategory":"ClientError","@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionMessageName":"IsvAborted","@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionHttpStatusCode":"400","@Microsoft.PowerApps.CDS.ErrorDetails.OperationStatus":"0","@Microsoft.PowerApps.CDS.ErrorDetails.SubErrorCode":"-2146233088","@Microsoft.PowerApps.CDS.ErrorDetails.Plugin.PluginTrace":"[Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]\r\n[3abd7e64-8b32-ef11-8e4e-000d3acb86b9: ]\r\nStarting sync workflow 'DocumentManagementIntegration', Id: 29bd7e64-8b32-ef11-8e4e-000d3acb86b9\r\nEntering CustomActivityStep1_step: API Calls\r\nSync workflow 'DocumentManagementIntegration' terminated with error 'Error in DocumentManagementIntegration: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.61.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'","@Microsoft.PowerApps.CDS.TraceText":"\r\n[Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]\r\n[3abd7e64-8b32-ef11-8e4e-000d3acb86b9: ]\r\nStarting sync workflow 'DocumentManagementIntegration', Id: 29bd7e64-8b32-ef11-8e4e-000d3acb86b9\r\nEntering CustomActivityStep1_step: API Calls\r\nSync workflow 'DocumentManagementIntegration' terminated with error 'Error in DocumentManagementIntegration: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.61.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'\r\n","@Microsoft.PowerApps.CDS.InnerError.Message":"Error in DocumentManagementIntegration: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.61.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"}}

Relevant code snippets

try
 {

     IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(clientId)
         .WithClientSecret(clientSecret)
         .WithAuthority(new Uri(authority))
         .Build();

     string[] scopes = new string[] { $"{resource}/.default" };

     AuthenticationResult result = await app.AcquireTokenForClient(scopes).ExecuteAsync();

     return result.AccessToken;
 }

Expected behavior

Assembly should load when called via the client side D365 entity form.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

ADAL worked until last night

Solution and workarounds

No response

bgavrilMS commented 3 days ago

This is a setup authoring error, not an MSAL issue. Check your build system.

bgavrilMS commented 3 days ago

Also, we strongly recommend that you use Microsoft.Identity.Web for ASP.NET website, not MSAL

MOHAMMEDFAKHRI commented 3 days ago

Hi, your recommendation is primarily targeted towards web applications rather than CRM plugins or custom actions​. We are getting this error in CRM Custom Action.