Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net ClosedXML-无法加载文件或程序集_.net_Closedxml - Fatal编程技术网

.net ClosedXML-无法加载文件或程序集

.net ClosedXML-无法加载文件或程序集,.net,closedxml,.net,Closedxml,我正在尝试使用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 s

我正在尝试使用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 Studio 2010,dll属性不包含“复制本地”条目。然后,当我在web配置中输入以下程序集时,仍然会收到相同的服务器错误消息。我从提供的错误消息中获取程序集

 <add assembly="ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b"/>

在疯狂地搜索答案并最终发布了一个问题后,我找到了最简单的答案,一旦我引用了附加的.dll,一切正常

要使用ClosedXML,必须引用DocumentFormat.OpenXml.dll:


DocumentFormat.OpenXml.dll for NET 4.0+

我也遇到了同样的问题,但我只是添加了nuget包,并确保在我的项目中由

using ClosedXML.Excel;
然后,我可以使用访问excel文件

var wb = new XLWorkbook(MyExcelFile);

我也有同样的问题。我在Nugget中搜索“ClosedXML.Signed”,更新“DocumentFormat.OpenXml”,它就工作了

我也犯了这个错误。Visual Studio 2017,C#,使用Nuget ClosedXML和更新的所有相关依赖项。所有这些都在Visual Studio 2017开发PC(Windows 10)上运行良好,但在我将该版本复制到Windows Server 2016时失败。我没有此问题,无法将xcopy复制到Windows Server 2012 R2。我希望有人能找到答案。我无法让nuget ClosedXML在Windows Server 2016中工作,因为它出现了“无法加载文件或程序集…”错误。然而,当我从github下载ClosedXML的源代码并构建引用该源代码的应用程序时,所有这些都运行良好。