Problem when executing on robot (Could not load file or assembly 'System.Text.Json, Version=7.0.0.0)

So i have made an application that invokes code for WebDriverManager (selenium), and when i debug it in studio it works fine, but if i publish it to orchestrator and run it on my robot i get the below error:

RemoteException wrapping System.TypeInitializationException: The type initializer for ‘WebDriverManager.Clients.ChromeForTestingClient’ threw an exception. —> RemoteException wrapping System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral

It makes no sense since it should be using 7.0.3, which is the newest version installed from the package webdrivermanager, but it looks for 7.0.0 for some reason. I figured this might be related to Office365 activities, but i can’t find anyone who have the same error for 7.0.0, in a windows project.

I’ve tried installing System.Text.Json version 7.0.3 (it won’t let me install 7.0.0 due to webdrivermanager using a newer version), but that doesn’t help, neither does importing it to the namespace. I’ve tried a bunch of things with no luck, so i’m hoping i can get some help here. It seems to be a bug that also appears in visual studio. FileLoadException with System.Text.Json when upgrading to v2.17.0 · Issue #257 · rosolko/WebDriverManager.Net (github.com)

I hoped it was due to our robot only being 2022.4.X, so i downgraded Mail Activities to 1.18.2 and Office365 to 1.14.1 to match the UiPath.platform which took a hell of a time because the activities changed in newer versions, so i had to rebuild it all, and it still didn’t work…

Here are my dependencies:

    "EPPlus": "[6.2.10]",
    "ExcelDataReader": "[3.6.0]",
    "ExcelDataReader.DataSet": "[3.6.0]",
    "Selenium.Support": "[4.10.0]",
    "Selenium.WebDriver": "[4.10.0]",
    "System.Text.Json": "[7.0.3]",
    "UiPath.Excel.Activities": "[2.22.2]",
    "UiPath.Mail.Activities": "[1.18.2]",
    "UiPath.MicrosoftOffice365.Activities": "[1.14.1]",
    "UiPath.System.Activities": "[23.4.5]",
    "UiPath.Testing.Activities": "[23.4.1]",
    "UiPath.UIAutomation.Activities": "[23.4.8]",
    "WebDriverManager": "[2.17.1]"

@farow31916

The error is because of some dependency conflicts

One work around is as it is working in debug or on studio you can copy the .nuget folder of your dev machien to the target machine where you are running from orchestrator

C:\users\<username>\.nuget

Basically the error is because of some dependencies …alternate to copying you can rename .nuget and let yhe dependencies download again so that when newly downlaoded they might be resolved

Copy might work because on dev already all the versions might have been downloaded

Cheers

This didn’t work unfortunately…

@farow31916

Both copying and renaming are tried?

Are both the tobot and studio of same versions?

Whichever version is creating a conflict can we try to change the versions and see if that works

Cheers

    <add key="Official" value="https://pkgs.dev.azure.com/uipath/Public.Feeds/_packaging/UiPath-Official/nuget/v3/index.json" />
    <add key="Connect" value="https://gallery.uipath.com/api/v3/index.json" />
    <add key="MyGet" value="https://pkgs.dev.azure.com/uipath/Public.Feeds/_packaging/UiPath-Official/nuget/v3/index.json" />
    <add key="MyGetOrg" value="https://www.myget.org/F/workflow/" />
    <add key="Marketplace" value="https://gallery.uipath.com/api/v2" />
    <add key="UiPath Packages" value="https://packages.uipath.com/activities" />
    <add key="nugetv3.org" value="https://api.nuget.org/v3/index.json" />
    <add key="UiPath Official" value="https://uipath.pkgs.visualstudio.com/Public.Feeds/_packaging/UiPath-Official/nuget/v3/index.json" />
  • Close any Studio instances.
  • Go to %userprofile%\.nuget and rename the packages folder to pacakges_backup.
  • Reopen the Main.xaml, repair the not installed dependencies and retry to publish the project to your Orchestrator.

I don’t have permissions to modify our robot machines, but so far i’ve gotten our support to update the robot to 2023.4.5, that didn’t work. Nor did renaming the packages folder to packages_backup and opening the main.xaml and repairing the not installed dependencies unfortunately… I wasn’t allowed to close all UiPath processes however due to my limited permissions, so i’ve asked support to do that and then rename the packages folder, and now they have, it didn’t help.

I assume the last 4 steps are for the robotmachine, but i tried it on my developing machine aswell and published it to the orchestrator and it didn’t help. I also tried different versions of the webdrivermanager but to no luck. It has to be a newer version to work with the current chrome version.

I think the System.Text.Json version from the WebDriverManager library is not compatible with the other packages.

Try to downgrade the WebDriverManager to 2.16.2 to not resolve the System.Text.Json for other activities.

Also, remove the “System.Text.Json”: “[7.0.3]” from the dependencies.

I was already exploring this path and solved it by not using webdrivermanager, but the reason i use webdrivermanager is due to the built in manager for selenium has issues with UiPath, and downgrading it resulted in bugs. I fixed the selenium manager with a code snippet i wrote here: [:bug: Bug]: Issue with UiPath studio and selenium manager binary location [4.15.0] · Issue #13137 · SeleniumHQ/selenium (github.com)

string[] pathParts = System.IO.Path.GetDirectoryName(typeof(OpenQA.Selenium.By).Assembly.Location).Split(Path.DirectorySeparatorChar);

int seleniumFolderIndex = Array.IndexOf(pathParts, "selenium.webdriver");
string newPath="";
if (seleniumFolderIndex != -1 && seleniumFolderIndex < pathParts.Length - 1)
{
    string versionFolder = pathParts[seleniumFolderIndex + 1];
    
    string versionFolderPath = string.Join("\\", pathParts.Take(seleniumFolderIndex + 2));
    DirectoryInfo versionDirectory = new DirectoryInfo(versionFolderPath);
    
    newPath = Directory.GetFiles(versionDirectory.FullName, "*manager*.exe", SearchOption.AllDirectories).FirstOrDefault();
    System.Environment.SetEnvironmentVariable("SE_MANAGER_PATH", newPath);
}

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.