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.

3 Likes

Hi. Do you have any update in when you will have this fix for Office365 activities to work with the updated package from Microsoft? I am having the same problem and even with the two possible workarounds, I could only get my Microsoft Teams Scope to work on one workstation. It’s now 2021 and I don’t see any update on this thread indicating a fix is available.

For the record, here is the error I am seeing when using the UiPath.Mail.Activities:

Microsoft Teams Scope - ACME Azure Tenant: Could not load type ‘Microsoft.Identity.Client.TokenCacheExtensions’ from assembly ‘Microsoft.Identity.Client, Version=4.14.0.0, Culture=neutral, PublicKeyToken=’.

I would like to have a permanent fix as this makes it difficult to perform basic Office 365 integration with UiPath. I am using UiPath Studio 2020.10.0, for what it’s worth.

Thank you.

@itprofessional the issue in this thread was specifically in the context of the Official Office 365 activities which was fixed with the August release of the UiPath.MicrosoftOffice365.Activities package (v 1.3.1)

Just to clarify, it sounds like you are reporting an issue with the UiPath.MicrosoftTeams.Activities running into the same dependency problem? I will follow up with that team that owns the Teams activities regarding getting those activities fixed to upgrade their dependency. We appreciate you bringing this to our attention.

Yes, correct. I am using the UiPath.Microsoft.Teams.Activities v0.4.0 package and seeing the same type of identity client token cache extension error as the OP.

@AndrewHall Hi! Any status update on when the team that manages code for the Microsoft Teams activities might have a new package available to resolve the issue with the Microsoft.Identity.Client.TokenCacheExtensions noted above? I am just trying to get a sense for when an update might be available as I have a project that relies on the UiPath.MicrosoftTeams.Activities package? Thank you in advance.

I don’t currently have an ETA from them, but I asked them to follow up directly with you here.

@AndrewHall Thank you sir. If that team needs someone in the field to test the updated package for them, I would be glad to test and provide my feedback.

I am receiving this error RemoteException wrapping System.TypeLoadException: Could not load type ‘Microsoft.Identity.Client.TokenCacheExtensions’ from assembly ‘Microsoft.Identity.Client,
Version=4.14.0.0,
Culture=neutral,
PublicKeyToken=0a613f4dd989e8ae’.
at UiPath.MicrosoftTeams.Activities.Office365TeamsApplicationScope.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance,
ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation) in microsoft teams scope. I followed the instructions for the setup page, i worked together with the company admin but im still receiving the same error

2 Likes

ANy update on the above issue ? @AndrewHall

Hi - the current release of Teams is 0.5.1 which was released in March of 2021. Do you encounter the same issue if you upgrade? The 0.4.0 is not supported currently.