EPPlus Could not load file or assembly 'Microsoft.IO.RecyclableMemoryStream

Viewed 2173

I am using the EPPlus v5.7.5 library in my C# project. When I use my code which generates an excel file, the code works during Visual Studio debugging. After installing the same application via MSI setup (created in VS 2019), I can't create the excel file because I get the follwing error:

Could not load file or assembly 'Microsoft.IO.RecyclableMemoryStream, Version=1.4.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at OfficeOpenXml.Utils.RecyclableMemory.GetStream()
   at OfficeOpenXml.ExcelPackage.ConstructNewFile(String password)
   at OfficeOpenXml.ExcelPackage..ctor(FileInfo newFile)
   at Utilities.General.Files.Excel.EPPlusHandler.GenerateExcelFile(DataTable dataTable, ExtendedFileDetails fileDetails, Dictionary`2 alignment, Boolean isDotNetFramework, Action`1 exceptionHandler)

I am using Microsoft.IO.RecyclableMemoryStream, Version=2.1.3.0 because on the EPPlus library documentation they mentioned that we can use v>= v1.4

** The code is located on a common project. If I use it from another project, it request the RecyclableMemoryStream v2.1.2.

What should I do to fix it? I want to use the latest version of both nugets. Currently I an using in each project a different version of the nuget to overcome this...

2 Answers

Try re-installing Microsoft.IO.RecyclableMemoryStream from Nuget. That helped me once I had a similar issue.

Microsoft.IO.RecyclableMemoryStream dll missing in the location. just place Microsoft.IO.RecyclableMemoryStream dll

Related