Microsoft Office 365 Scope: Could not load type 'Microsoft.Identity.Client.TokenCacheExtensions'

I’ve run into this issue on StudioX (2020.6.0-beta.93) on a couple of different Windows 10 PCs. I started a new Process, added UiPath.MicrosoftOffice365.Activities (1.3.0) to the project dependencies, then added a Microsoft Office 365 Scope as the only element in the process. When I debug the process it immediately errors with:
“Microsoft Office 365 Scope: Could not load type ‘Microsoft.Identity.Client.TokenCacheExtensions’ from assembly ‘Microsoft.Identity.Client, Version=4.14.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae’.”

I notice that when I setup Studio X I asked for the ‘stable’ channel, but it reports its version as a beta - not sure if this is a factor.

Does anyone know what I need to do to fix this? Thanks.

At this time the Office365 activities are not designed for use with StudioX. If you need these activities, we would recommend using them with the Studio profile rather than StudioX. Office 365 support is on our backlog, but it will be multiple months before it’s available.

Sorry, got mixed up in the editions - this is happening in “Studio Pro Community”

The issue here looks like a missing dependency from one of the Microsoft libraries. If you look at your package feeds, can you make sure that you have a nuget.org feed (https://api.nuget.org/v3/index.json) present and active?

The nuget.org feed is present. I ended up doing a workaround.

I got this from the fusion logs:

*** Assembly Binder Log Entry  (25/06/2020 @ 11:00:48 am) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\Owner\AppData\Local\UiPath\app-20.6.0-beta0093\UiPath.Executor.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Identity.Client, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Owner/AppData/Local/UiPath/app-20.6.0-beta0093/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = UiPath.Executor.exe
Calling assembly : UiPath.MicrosoftOffice365, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\Owner\AppData\Local\UiPath\app-20.6.0-beta0093\UiPath.Executor.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Identity.Client, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/Owner/AppData/Local/UiPath/app-20.6.0-beta0093/Microsoft.Identity.Client.DLL.
LOG: Attempting download of new URL file:///C:/Users/Owner/AppData/Local/UiPath/app-20.6.0-beta0093/Microsoft.Identity.Client/Microsoft.Identity.Client.DLL.
LOG: Attempting download of new URL file:///C:/Users/Owner/AppData/Local/UiPath/app-20.6.0-beta0093/Microsoft.Identity.Client.EXE.
LOG: Attempting download of new URL file:///C:/Users/Owner/AppData/Local/UiPath/app-20.6.0-beta0093/Microsoft.Identity.Client/Microsoft.Identity.Client.EXE.
LOG: Attempting download of new URL file:///C:/Users/Owner/.nuget/packages/uipath.microsoftoffice365.activities/1.3.0/lib/net461/Microsoft.Identity.Client.DLL.
LOG: Attempting download of new URL file:///C:/Users/Owner/.nuget/packages/uipath.microsoftoffice365.activities/1.3.0/lib/net461/Microsoft.Identity.Client/Microsoft.Identity.Client.DLL.
LOG: Attempting download of new URL file:///C:/Users/Owner/.nuget/packages/uipath.microsoftoffice365.activities/1.3.0/lib/net461/Microsoft.Identity.Client.EXE.
LOG: Attempting download of new URL file:///C:/Users/Owner/.nuget/packages/uipath.microsoftoffice365.activities/1.3.0/lib/net461/Microsoft.Identity.Client/Microsoft.Identity.Client.EXE.
LOG: All probing URLs attempted and failed.

So I manually downloaded Microsoft.Idenity.Client 2.7.1 from nuget.org and added it to C:/Users/Owner/AppData/Local/UiPath/app-20.6.0-beta0093

The activity is now working

@Simon_Hardman @AndrewHall

I am receiving the below error and i am new to ui path. Please help me resolve this error.

{
“message”: “Microsoft Office 365 Scope: Could not load type ‘Microsoft.Identity.Client.TokenCacheExtensions’ from assembly ‘Microsoft.Identity.Client, Version=4.15.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae’.”,
“level”: “Error”,
“logType”: “Default”,
“timeStamp”: “20:58:15”,
“processVersion”: “1.0.0”,
“jobId”: “309178cc-2403-447b-9783-8605239e427b”,
“robotName”: “P01242”,
“machineId”: 0,
“fileName”: “Main”
}

What I did, which is probably not the correct fix but just a workaround is:

Download https://www.nuget.org/api/v2/package/Microsoft.Identity.Client/2.7.1

Open the downloaded .nupkg file in a zip archive tool (e.g. 7zip). Extract the file Microsoft.Identity.Client.dll from the folder lib/net45 inside the archive. Drop the file Microsoft.Identity.Client.dll into c:\users<your username>\appdata\local\uipath\app-\

2 Likes

For anyone else running into this, the issue at the moment is updates to the UiPath.Mail.Activities package are pulling in an updated version of the “Microsoft.Identity.Client” package which has breaking changes so causes errors in the O365 activities because the newer version gets loaded first at runtime. There are two possible workarounds to this:

  • Easiest: If you are not using any of the other mail activities, remove the reference to “UiPath.Mail.Activities” from the project
  • If you need other mail activities, in the package manager, downgrade the version of the mail activities to 1.8.6.

We are working on getting a fix to the Office365 activities to work with the updated package from Microsoft.