如何在Mono2.10上包含DocumentFormat.OpenXml.dll的引用?
我正在使用 C#.net Windows 桌面应用程序。我也想在其他平台上运行这些应用程序。因此,我使用 Mono 2.10 作为交叉编译器。运行时,我的应用程序意外终止,并显示类似
错误:无法打开所选文件夹的错误消息。
无法加载文件或程序集“DocumentFormat.OpenXml.dll,version=2.0.5022.0,culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。
我不知道这里出了什么问题...我已在 c:\program files\open xml sdk\v2\lib\DocumentFormat.OpenXml.dll 上安装了 openxml sdk2.0。
并将我的应用程序 eXe 放在同一位置以进行测试...
请指导我解决这个问题...
I am using C#.net Windows Desktop Application.I want to run these application with other platform also. So, i am using Mono 2.10 as a cross compiler.While running,unexpectedly my Application is terminated by saying the error message like
Error:Could not open the selected folder.
Could not load a file or assembly 'DocumentFormat.OpenXml.dll,version=2.0.5022.0, culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
I don't know what is problem here...I have installed openxml sdk2.0 on c:\program files\open xml sdk\v2\lib\DocumentFormat.OpenXml.dll.
and also put my application eXe on on the same place for testing purpose...
Please guide me to solve this issue...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
对我有用的方法:
ThirdParty
。ThirdParty
文件夹中添加DocumentFormat.OpenXML.dll
和WindowsBase.dll
ThirdParty
> dir 作为 DLLWhat worked for me:
ThirdParty
.ThirdParty
folder bothDocumentFormat.OpenXML.dll
andWindowsBase.dll
ThirdParty
dir as reference for both the DLLs好吧,在我的应用程序中,我只需要在 .Net 选项卡下添加对“DocumentFormat.OpenXml”的引用,并且两个引用(DocumentFormat.OpenXml 和 WindowsBase)始终会自动添加。但它们不包含在 Bin 文件夹中。因此,当应用程序发布到外部服务器时,我总是手动将 DocumentFormat.OpenXml.dll 放置在 Bin 文件夹下。或者将引用“复制本地”属性设置为 true。
Well, In my applications I just need to Add a reference to "DocumentFormat.OpenXml" under .Net tab and both references (DocumentFormat.OpenXml and WindowsBase) are always added automatically. But They are not included within the Bin folder. So when the Application is published to an external server I always place DocumentFormat.OpenXml.dll under the Bin folder manually. Or set the reference "Copy Local" property to true.
您需要将 DocumentFormat.OpenXML.dll 放在与您的应用程序相同的文件夹中,或者如果您正在开发 ASP.NET 应用程序,则将其放在“bin”路径中。但是,我不确定非 Windows 操作系统是否支持 OpenXML SDK - 您可能需要研究第三方解决方案。
是的,这个答案是正确的,唯一的区别是您将 .dll 复制到项目的 bin 文件夹中。
You need to have DocumentFormat.OpenXML.dll in the same folder as your application - or in the 'bin' path if you are developing an ASP.NET application. However, I'm not certain that the OpenXML SDK is supported on non-Windows operating systems - you may need to look into a third-party solution.
Yes, this answer is right, the only difference is that you copy your .dll into bin folder of the project.
查看并将属性更改为 DocumentFormat.OpenXml 后,我还必须将特定版本更改为 false。
After viewing and changed the properties to DocumentFormat.OpenXml, I also had to change the Specific Version to false.
我发现与 PCL 库混合时会出现上述问题,虽然 WindowsBase 库确实包含 System.IO.Packaging 我正在使用 OpenXMLSDK-MOT 2.6.0.0 库,它本身提供了自己的物理系统副本.IO.封装库。我所缺少的参考可以在 csharp 项目中找到,如下所示,
我将 XMLSDK 版本降级到 2.6,然后似乎为我解决了这个问题。但可以看到有一个物理程序集System.IO.Packaging.dll
I found that when mixed with PCL libraries the above problem presented itself, and whilst it is true that the WindowsBase library contains System.IO.Packaging I was using the OpenXMLSDK-MOT 2.6.0.0 library which itself provides it's own copy of the physical System.IO.Packaging library. The reference that was missing for me could be found as follows in the csharp project
I downgraded my version of the XMLSDK to 2.6 which then seemed to fix this problem up for me. But you can see there is a physical assembly System.IO.Packaging.dll
对我来说,问题是我的 Win7 开发盒上的全局程序集缓存 (GAC) 中存在
DocumentFormat.OpenXml.dll
。因此,当在 VS2013 中发布我的项目时,它在 GAC 中找到了该文件,因此省略了将其复制到发布文件夹的操作。解决方案:从 GAC 中删除 DLL。
%windir%\Microsoft.NET\ assembly
)OpenXml
可能有一种更合适的方法来删除 GAC 文件(如下),但这就是我所做的并且它有效。
gacutil –u DocumentFormat.OpenXml.dll
希望有帮助!
The issue for me was that
DocumentFormat.OpenXml.dll
existed in the Global Assembly Cache (GAC) on my Win7 development box. So when publishing my project in VS2013, it found the file in the GAC and therefore omitted it from being copied to the publish folder.Solution: remove the DLL from the GAC.
%windir%\Microsoft.NET\assembly
)OpenXml
There may be a more proper way to remove a GAC file (below), but that is what I did and it worked.
gacutil –u DocumentFormat.OpenXml.dll
Hope that helps!
由于我本人对此不熟悉,因此我所做的如下:
我正在使用 MS Visual Studio 2010 Pro。
C:\Program Files(x86)\Open XML SDK\V2.0\lib 并选择“DocumentFormat.OpenXml.dll
您现在应该可以使用 DocumentFormat 类来运行。
Being new to this myself, here's what I did:
I'm using MS Visual Studio 2010 Pro.
C:\Program Files(x86)\Open XML SDK\V2.0\lib and select the "DocumentFormat.OpenXml.dll
You should be off and running now using the DocumentFormat classes.
您还应该确保设置对
WindowsBase
的引用。这是使用 SDK 所必需的,因为它处理 System.IO.Packaging(用于将压缩的 .docx/.xlsx/.pptx 作为 OPC 文档解压和打开)。You should also ensure you set a reference to
WindowsBase
. This is required to use the SDK as it handlesSystem.IO.Packaging
(which is used for unzipping and opening the compressed .docx/.xlsx/.pptx as an OPC document).选择引用下的 DocumentFormat.OpenXml,查看其属性,然后将复制本地选项设置为 True,以便将其复制到输出文件夹。这对我有用。
select DocumentFormat.OpenXml under references , view it's properties, and set the Copy Local option to True so that it copies it to the output folder. That worked for me.
转到 Nuget 包管理器并搜索 openxml。并安装 DocumentFormat.OpenXml
Goto Nuget Package manager and search for openxml. And install DocumentFormat.OpenXml