Cannot load assembly: E:\Nuget\XXXXXXX\npoi\2.2.1\lib/net40/NPOI.OpenXml4Net.dll : System.TypeLoadException

hi Team,

We were required to update all of the packages that are <=19.XX to >=22.XX as part of a PLM at our company. When we attempt to upgrade UiPath.System.Actvities in one of my current automations to a version greater than 20.XX, we see the problem listed below:

Cannot load assembly: E:\Nuget\XXXXX\npoi\2.2.1\lib/net40/NPOI.OpenXml4Net.dll : System.TypeLoadException:
Inheritance security rules violated by type: ‘NPOI.OpenXml4Net.Util.ZipInputStreamZipEntrySource+FakeZipEntry’.
Derived types must either match the security accessibility of the base type or be less accessible.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at UiPath.Studio.Plugin.Workflow.Services.AssemblyContainerBase.AddAssemblyInternal(Assembly assembly, String path)
at UiPath.Studio.Plugin.Workflow.Services.AssemblyContainerBase.<>c__DisplayClass15_0.b__0(Tuple`2 range)

We have attempted to update UiPath.UIAutomation in accordance with this change as well.Activities to >=20 were similarly unsuccessful.

Any Suggestion will be helpful.

Thanks
Harsha

@harshavardhan3457,

Try this approach.

  1. Close the project from Studio
  2. Take copy of project.json and delete the project.json from project.
  3. Open Main.xaml
  4. Now Studio will create the project.json with all dependencies. It will be able to find all package and dependencies.

Thanks,
Ashok :slight_smile:

I appreciate your prompt reply. I attempted to follow your advice, however it resulted in the removal of all project-related packages and additionally some of the packages have got migrated to version 2022.
The system and UiPath restart have worked for me; I’m not sure why.

@harshavardhan3457,

Glad it worked :smiley:
May be due to some temp memory of the Studio could have resulted in this.

Thanks,
Ashok :slight_smile: