ClosedXML - 无法加载文件或程序集
ClosedXML - Could not load file or assembly
我正在尝试使用 ClosedXML 在应用程序中生成 excel 文档,但是当我尝试 运行 它时,我收到无法加载文件或程序集服务器错误。
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
我见过几个解决方案,包括更改 .dll 属性中的 'Copy Local' 值,并将程序集直接添加到 web.config。
我使用的是 Visual Studios 2010,dll 属性不包含 'copy local' 条目。然后,当我在 Web 配置中输入以下程序集时,我仍然收到相同的服务器错误消息。我从提供的错误消息中得到了程序集。
<add assembly="ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b"/>
疯狂搜索答案并最终发布问题后,我找到了最简单的答案,一旦我引用了额外的 .dll,一切正常。
要使用 ClosedXML,您必须引用 DocumentFormat.OpenXml.dll:
DocumentFormat.OpenXml.dll 对于 NET 4.0+
我遇到了同样的问题,但我只是添加了 nuget 包并确保它在我的项目中被正确引用
using ClosedXML.Excel;
然后我可以使用
访问excel文件
var wb = new XLWorkbook(MyExcelFile);
我有同样的问题。我在 Nugget 中搜索 "ClosedXML.Signed",更新 "DocumentFormat.OpenXml" 并且有效!
这对我有用:
为后代复制这里:
There is a open issue on this here
https://github.com/NuGet/Home/issues/4837
Try unloading the project, right click on the project, edit. Add the
following
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Save, reload, build.
我仔细检查了这里的每个答案,但没有任何效果。我解决这个问题的方法是通过 NuGet 包管理器将 ClosedXML 回滚到 v0.90.0。然后我的错误消息变成了抱怨需要 DocumentFormat.OpenXML 依赖项的 v2.16.0。因此,再次通过 Nuget 包管理器,我将已安装的 DocumentFormat.OpenXML 版本更改为 v2.16.0。然后它起作用了。要让一个简单的 DLL 工作,要经历多么可怕的废话啊。哦,我也知道一个事实,几个月前它一切正常,几个月后我在我的项目中使用这个功能时才发现有些东西发生了变化。
我正在尝试使用 ClosedXML 在应用程序中生成 excel 文档,但是当我尝试 运行 它时,我收到无法加载文件或程序集服务器错误。
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
我见过几个解决方案,包括更改 .dll 属性中的 'Copy Local' 值,并将程序集直接添加到 web.config。
我使用的是 Visual Studios 2010,dll 属性不包含 'copy local' 条目。然后,当我在 Web 配置中输入以下程序集时,我仍然收到相同的服务器错误消息。我从提供的错误消息中得到了程序集。
<add assembly="ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b"/>
疯狂搜索答案并最终发布问题后,我找到了最简单的答案,一旦我引用了额外的 .dll,一切正常。
要使用 ClosedXML,您必须引用 DocumentFormat.OpenXml.dll:
DocumentFormat.OpenXml.dll 对于 NET 4.0+
我遇到了同样的问题,但我只是添加了 nuget 包并确保它在我的项目中被正确引用
using ClosedXML.Excel;
然后我可以使用
访问excel文件var wb = new XLWorkbook(MyExcelFile);
我有同样的问题。我在 Nugget 中搜索 "ClosedXML.Signed",更新 "DocumentFormat.OpenXml" 并且有效!
这对我有用:
为后代复制这里:
There is a open issue on this here
https://github.com/NuGet/Home/issues/4837
Try unloading the project, right click on the project, edit. Add the following
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Save, reload, build.
我仔细检查了这里的每个答案,但没有任何效果。我解决这个问题的方法是通过 NuGet 包管理器将 ClosedXML 回滚到 v0.90.0。然后我的错误消息变成了抱怨需要 DocumentFormat.OpenXML 依赖项的 v2.16.0。因此,再次通过 Nuget 包管理器,我将已安装的 DocumentFormat.OpenXML 版本更改为 v2.16.0。然后它起作用了。要让一个简单的 DLL 工作,要经历多么可怕的废话啊。哦,我也知道一个事实,几个月前它一切正常,几个月后我在我的项目中使用这个功能时才发现有些东西发生了变化。