EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Assembly load failure

Open swfaust opened this issue 1 year ago • 3 comments

EPPlus usage

Commercial use (I have a commercial license)

Environment

Windows 11

Epplus version

7.1.2

Spreadsheet application

Excel

Description

I have an application that exports Excel files and is an addin to another application (Autodesk Revit is the parent application). I am currently referencing EPPlus 6.2.19 and all is working well. When I upgrade to EPPlus 7.1.2 I start getting errors. When I call the line using (var ep = new ExcelPackage(fileInfo)) I get this error:

Could not load file or assembly 'Microsoft.Extensions.Configuration.FileExtensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)

I have looked in the compile directory and that file exists (it is version 8.0.23). I also have an assembly resolve handler that should handle loading things from the same directory if necessary and that function never gets called for this dll. I get no compilation errors and no other code changed (we have a fairly simple implementation). Looking through my packages tree, this is a dependency of Microsoft.Extensions.Configuration.Json which is a dependency of EPPlus. When I roll back to 6.2.19 it references this same package but version 7.0 of it and all seems to work.

swfaust avatar Apr 25 '24 17:04 swfaust

Did some more experimentation between versions and this happened at version 7.0.3. I can use 7.0.2 just fine but when I move up to 7.0.3 it starts throwing the exception. I also noticed that this is when the package specifically starts targeting .NET 8.0 (which is what Revit 2025 uses hence we do too). It seems like possibly something is off in the 8.0 support?

swfaust avatar Apr 25 '24 18:04 swfaust

Hello!

We seem to have issues replicating your issue. Could you create a new project that replicates this error for us to look at?

AdrianEPPlus avatar Apr 26 '24 08:04 AdrianEPPlus

Ok so after experimenting more it may be something in the way that Revit is loading this. I figured out that my unit tests that run as their own process are passing and exporting successfully in the newer versions as well, even though inside Revit it's not working. I need to delve into it further to see if there is anything else in the unit tests that would cause it to work when the addin application does not. I've also asked Autodesk about this to see if they know why it would be throwing the error. I will see if I can create a reproducible example outside of Revit and get back to you.

swfaust avatar Apr 26 '24 16:04 swfaust

I'll close this issue for now. Please re-open it if you can attach a way to reproduce this.

JanKallman avatar Jul 25 '24 05:07 JanKallman