Cannot load Assembly

Hi

Getting the following error in invoke code activity doing Excel operations in it
→ added the namespace in imports.
–>added the package microsoft.office.interop.excel.

Cannot load assembly: C:\Users\XXXX.nuget\packages\microsoft.office.interop.excel/15.0.4795.1000\lib/net20/Microsoft.Office.Interop.Excel.dll : System.IO.FileNotFoundException: Could not load file or assembly ‘office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
File name: ‘office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at UiPath.Studio.Plugin.Workflow.Services.AssemblyContainer.AddAssemblyInternal(Assembly assembly, String path)
at UiPath.Studio.Plugin.Workflow.Services.AssemblyContainer.LoadAssemblies(String paths, IAppDomainCancellationToken cancellationToken)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Regards,
A Manohar

You can install it from the packages @Manohar1

  1. Go to manage packages
  2. search for microsoft.office.interop.excel\
  3. Install it

@HareeshMR

Getting this error

19.3.0+Branch.master.Sha.5fdb43627d7d3c011018bb545ddf9470210d44a9

Source: Invoke Code

Message: Exception has been thrown by the target of an invocation.

Exception Type: System.Reflection.TargetInvocationException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ----> System.IO.FileNotFoundException: Could not load file or assembly ‘office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
at UiPathCodeRunner_6f8be8e01ea348f7b9292f01711c8f0c.Run(String files, String firstRange, String secondRange, String newfile)
— End of inner ExceptionDetail stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Core.Activities.Workflow.CompilerRunner.Run(Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.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)

File not found exception @Manohar1

May be the path you are providing has no file

@HareeshMR

File is present in the location,checked with it.

May be some spaces is affecting

Copy the entire path and try to open the same in the file manager. @Manohar1

Or can you post what are you trying to do I mean, the piece of code you have

@HareeshMR
copying the data from one sheet and paste to other sheet.

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1,ws2 As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.Application
wb1 = excel.Workbooks.Open(files)
ws1 = CType(wb1.Sheets(“Sheet2”), Microsoft.Office.Interop.Excel.Worksheet)
ws2 = CType(wb1.Sheets(“Sheet1”), Microsoft.Office.Interop.Excel.Worksheet)
ws1.Activate()
ws2.Activate()
ws1.Range(firstRange).Copy
ws2.Range(secondRange).PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteValuesAndNumberFormats)
ws1.Delete()
wb1.SaveAs(newfile)
wb1.Close()
excel.Quit()

Can you please check if you are sending the files argument value correctly @Manohar1?

@HareeshMR

arguments are coming fine.

I have been executing this process from past 4 months,now i am getting this errors.

May be the new file in the folder having some spaces in the name @Manohar1

@HareeshMR

File.Folder names are correct only.

may be the problem with assembly reference itself.

Just give a try , remove the namespace you have added and then install from manage packages. then check.

But as it is working from last three months, how the reference missed now?

Have you found a solution @Manohar1 ?

@edward.hulleman

I raised a ticket to the UiPath Team,They suggested me to reinstall the UiPath or update to latest version.

As i didn’t get approval to do it,I created a new project and replicated the same process now it is working fine from me.

Regards,
A Manohar

Thank you @Manohar1.
In my case a restart of the development machine did the trick.

Edward

2 Likes