如何在Mono2.10上包含DocumentFormat.OpenXml.dll的引用?

发布于 2024-10-21 19:22:58 字数 447 浏览 11 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

水中月 2024-10-28 19:22:59

对我有用的方法:

  1. 向项目中添加一个文件夹,将其命名为 ThirdParty
  2. ThirdParty 文件夹中添加 DocumentFormat.OpenXML.dllWindowsBase.dll
  3. 确保项目使用 ThirdParty > dir 作为 DLL
  4. 构建和发布到外部服务器的参考。

What worked for me:

  1. Add a folder to the project call it ThirdParty.
  2. Add in the ThirdParty folder both DocumentFormat.OpenXML.dll and WindowsBase.dll
  3. Make sure the the project uses the ThirdParty dir as reference for both the DLLs
  4. Build and published to an external server.
十六岁半 2024-10-28 19:22:59

好吧,在我的应用程序中,我只需要在 .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.

对你再特殊 2024-10-28 19:22:59

您需要将 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.

星星的轨迹 2024-10-28 19:22:59

查看并将属性更改为 DocumentFormat.OpenXml 后,我还必须将特定版本更改为 false。

After viewing and changed the properties to DocumentFormat.OpenXml, I also had to change the Specific Version to false.

一抹淡然 2024-10-28 19:22:59

我发现与 PCL 库混合时会出现上述问题,虽然 WindowsBase 库确实包含 System.IO.Packaging 我正在使用 OpenXMLSDK-MOT 2.6.0.0 库,它本身提供了自己的物理系统副本.IO.封装库。我所缺少的参考可以在 csharp 项目中找到,如下所示,

<Reference Include="System.IO.Packaging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\..\..\packages\OpenXMLSDK-MOT.2.6.0.0\lib\System.IO.Packaging.dll</HintPath>
  <Private>True</Private>
</Reference>

我将 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

<Reference Include="System.IO.Packaging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\..\..\packages\OpenXMLSDK-MOT.2.6.0.0\lib\System.IO.Packaging.dll</HintPath>
  <Private>True</Private>
</Reference>

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

伴梦长久 2024-10-28 19:22:59

对我来说,问题是我的 Win7 开发盒上的全局程序集缓存 (GAC) 中存在 DocumentFormat.OpenXml.dll。因此,当在 VS2013 中发布我的项目时,它在 GAC 中找到了该文件,因此省略了将其复制到发布文件夹的操作。

解决方案:从 GAC 中删除 DLL。

  1. 在 Windows 资源管理器中打开 GAC 根目录(Win7:%windir%\Microsoft.NET\ assembly
  2. 搜索 OpenXml
  3. 删除任何适当的文件夹(或者为了安全起见,将其删除到您的桌面,以防您想要恢复它们)

可能有一种更合适的方法来删除 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.

  1. Open the GAC root in Windows Explorer (Win7: %windir%\Microsoft.NET\assembly)
  2. Search for OpenXml
  3. Delete any appropriate folders (or to be safe, cut them out to your desktop in case you should want to restore them)

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!

箜明 2024-10-28 19:22:58

由于我本人对此不熟悉,因此我所做的如下:

我正在使用 MS Visual Studio 2010 Pro。

  1. 下载并安装 OpenXML SDK
  2. 在 Visual Studio 的项目中,选择“项目”,然后选择“添加引用”
  3. 选择“浏览”选项卡
  4. 在“查找范围:”下拉列表中,导航至:
    C:\Program Files(x86)\Open XML SDK\V2.0\lib 并选择“DocumentFormat.OpenXml.dll
  5. 点击确定”
  6. 在“解决方案资源管理器”(在我的右侧)中,“References”文件夹现在显示 DocumentFormat.OpenXML 库并选择“属性”。
  7. 右键单击
  8. 在“属性”面板中,将“Copy Local”更改为“True”。

您现在应该可以使用 DocumentFormat 类来运行。

Being new to this myself, here's what I did:

I'm using MS Visual Studio 2010 Pro.

  1. Download and install the OpenXML SDK
  2. Within my project in Visual Studio, select "Project" then "Add Reference"
  3. Select the "Browse" tab
  4. In the "Look in:" pull down, navigate to:
    C:\Program Files(x86)\Open XML SDK\V2.0\lib and select the "DocumentFormat.OpenXml.dll
  5. Hit OK
  6. In the "Solution Explorer" (on the right for me), the "References" folder now shows the DocumentFormat.OpenXML library.
  7. Right-click on it and select Properties
  8. In the Properties panel, change "Copy Local" to "True".

You should be off and running now using the DocumentFormat classes.

淡紫姑娘! 2024-10-28 19:22:58

您还应该确保设置对 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 handles System.IO.Packaging (which is used for unzipping and opening the compressed .docx/.xlsx/.pptx as an OPC document).

泼猴你往哪里跑 2024-10-28 19:22:58

选择引用下的 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.

断肠人 2024-10-28 19:22:58

转到 Nuget 包管理器并搜索 openxml。并安装 DocumentFormat.OpenXml

Goto Nuget Package manager and search for openxml. And install DocumentFormat.OpenXml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文