Could Not Load File Or Assembly UiPath.interop

How to resolve the Error running the workflow "Could not load file or assembly UiPath.interop" ?

Resolution: The workflow error “Could not load file or assembly UiPath.interop” can be approached as below -

Approach #1:

  1. Open %userprofile% in your affected Robot system
  2. Navigate to “.nuget” / packages / folder
1.jpg
  1. Delete the highlighted folder "uipath" in .nuget location.
Reason: This would delete all the dependent files thus allowing to Robot to download the files again when the process is executed.
  1. Now launch Studio/Robot & execute the process. This should complete the auto installation of dependent package
Reason: The process will download again the uipath dependencies i.e. uipath.interop.dll for the required version.
  1. Verify Now.

Approach #2: Take backup of the whole folder and delete the same.
  1. Open %userprofile% in your affected Robot system
  2. Navigate to “.nuget” folder
2.png
  1. Take a backup of the “packages” folder to a different location
  2. Delete the current folder in .nuget location i.e. packages folder itself
Reason: This would delete all the packages thus allowing to Robot to download the packages again when a process is executed.
  1. Now launch Studio & execute the process. This should complete the auto installation of dependent package
Reason: The process will download again with all the required dependencies.
  1. Verify Now.
2 Likes

What also might help is a code fix in the method “VerifyInteropCompatibility” method of the UiFactory class.

image

Version version1 = File.Exists(Path.Combine(this.NativeLibrariesFolder, fileName)) ? AssemblyName.GetAssemblyName(Path.Combine(this.NativeLibrariesFolder, "UiPath.Interop.dll")).Version : throw new Exception(string.Format("Custom UiPath native libraries base folder: '{0}' does not contain '{1}'.", this.NativeLibrariesFolder, fileName));

this.NativeLibrariesFolder translates to registry key “UIPATH_RUNTIME” which is set to: “C:\Users\XXXXXX.nuget\packages\uipath\20.10.XXXX.XXXXX\build\UiPath”. But in this folder the “UiPath.Interop.dll” is not present.

So either the UiPath.Interop.dll needs to be placed in this folder when installing UiPath (I did re-install UiPath twice in hope it would resolve the error.) or the code for calling the Interop Library should be changed to:

Version version1 = File.Exists(Path.Combine(this.NativeLibrariesFolder, fileName)) ? AssemblyName.GetAssemblyName(Path.GetFullPath(Path.Combine(this.NativeLibrariesFolder, "..\..\lib\UiPath.Interop.dll"))).Version : throw new Exception(string.Format("Custom UiPath native libraries base folder: '{0}' does not contain '{1}'.", this.NativeLibrariesFolder, fileName));

For your information this error started occuring when enabling the ‘Modern Design Experience’ in the project settings. I must say, it is quite an experience.

What solved the issue for me in the end is copying the UiPath.Interop.dll from the lib folder

C:\Users\XXXXXX\.nuget\packages\uipath\20.10.XXXX.XXXXX\lib

to

C:\Users\XXXXXX\.nuget\packages\uipath\20.10.XXXX.XXXXX\build\UiPath

Hope it helps!

2 Likes

A post was split to a new topic: Studio Error “Could not load type ’ UiPath.IUiElement’ From Assembly” thrown despite deleting and reinstalling from scratch UiPath Studio Community with latest MSI installer from Cloud Portal

I got the solution, its working properly.

Follow the below steps:
1)Just open “Project output folder”.
2)close the UiPath project
3)and delete all the folder starting with dot “.” ex: .nuget. in “project output folder”. 4)Now open the studio and run it, it will work for sure