【问题标题】:c# OpenXML error with Word Online files: Absolute URIs are not supportedc# Word Online 文件的 OpenXML 错误:不支持绝对 URI
【发布时间】:2017-10-02 16:16:12
【问题描述】:

我目前正在使用 OpenXml.Wordprocessing 来处理使用 Word Online 创建的 docx 文件。 使用 Word 保存的 docx 文件(不在线)我对命令没有问题:

using (var wdDocument = WordprocessingDocument.Open(fileName, true))

如果我使用相同的 docx 文件但使用 Word Online 保存,则会出现以下错误: targetUri 参数名称:不支持绝对 URI

使用调试器运行一些测试我注意到有问题的 URI 可能是 word/document.xml,但我不知道我可以通过哪种方式修复这些东西。

这里是堆栈跟踪:

”在 System.IO.Packaging.PackUriHelper.ResolvePartUri (System.Uri sourcePartUri, System.Uri targetUri) [0x0001a] 在 /private/tmp/source-mono-2017-02/bockbuild-2017-02 /profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/WindowsBase/System.IO.Packaging/PackUriHelper.cs:195 \n 在 DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships (DocumentFormat.OpenXml .Packaging.OpenXmlPackage openXmlPackage, DocumentFormat.OpenXml.Packaging.OpenXmlPart sourcePart, DocumentFormat.OpenXml.Packaging.RelationshipCollection relationshipCollection, System.Collections.Generic.Dictionary2[TKey,TValue] loadedParts) [0x00098] in <4ab5d094c38a4200ae0a70753476e093>:0 \n at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load (DocumentFormat.OpenXml.Packaging.OpenXmlPackage openXmlPackage, DocumentFormat.OpenXml.Packaging.OpenXmlPart parent, System.Uri uriTarget, System.String id, System.Collections.Generic.Dictionary2[TKey,TValue] loadedParts) [0x000fc] in :0 \n 在 DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load () [0x000f5] in :0 \n 在 DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open (System.String path, System.Boolean isEditable, DocumentFormat.OpenXml.Packaging.OpenSettings openSettings) [0x000a6] in :0 \n 在 DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open (System.String path, System.Boolean isEditable) [0x00007] in :0 \n

有什么想法吗?

【问题讨论】:

    标签: c# ms-word uri openxml


    【解决方案1】:

    好的,经过几次调试会话后,这似乎是单声道本身的问题。 这是 Uri 包实现的一个开放错误。 使用环境变量 MONO_URI_DOTNETRELATIVEORABSOLUTE=true mono app.exe 解决了问题,遵循http://www.mono-project.com/docs/faq/known-issues/urikind-relativeorabsolute/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多