加载大于 40MB 的流时出现 EPPLus 错误

EPPLus Error when loading a Stream larger than 40MB

我在 C# MVC 上使用 EPPlus 将 excel 文件加载到内存中。 我正在从文件上传中获取流:

model.File.InputStream

并将其传递给 ExcelPackage.Load() 方法。

它适用于小于 40 MB 的文件。但是对于较大的文件,我得到错误:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in EPPlus.dll but was not handled in user code

Additional information: A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))

将项目切换到 x64 解决了这个问题!

  • 如果您在 IIS 上使用它,您必须在 x64 上将池设置为 运行。
  • 在 IIS Express 上,您必须 Enable x64 bit version