wordpress hit counter
SOLVED: FileFormationException during Part.Save() Call: "Compression part has inconsistent data length" - Open Packaging Convention - Formats - OpenXML Developer

SOLVED: FileFormationException during Part.Save() Call: "Compression part has inconsistent data length"

Formats

Discussions about working with different Open XML Formats

FileFormationException during Part.Save() Call: "Compression part has inconsistent data length"

  • rated by 0 users
  • This post has 1 Reply |
  • 0 Followers
  • Unhandled System.IO.FileFormatException Message="Compression part has inconsistent data length" //note:- this is not the exact message but translated from chinese Source="WindowsBase" StackTrace: in MS.Internal.IO.Packaging.CompressStream.UpdateUncompressedDataLength(Int64 dataLength) in MS.Internal.IO.Packaging.CompressStream.Read(Byte[] buffer, Int32 offset, Int32 count) in MS.Internal.IO.Zip.Crc32Calculator.CalculateStreamCrc(Stream stream) in MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.CalculateCrc() in MS.Internal.IO.Zip.ZipIOLocalFileBlock.UpdateReferences(Boolean closingFlag) in MS.Internal.IO.Zip.ZipIOBlockManager.SaveContainer(Boolean closingFlag) in MS.Internal.IO.Zip.ZipIOBlockManager.SaveStream(ZipIOLocalFileBlock blockRequestingFlush, Boolean closingFlag) in MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Dispose(Boolean disposing) in System.IO.Stream.Close() in System.IO.Stream.Dispose() in DocumentFormat.OpenXml.OpenXmlPartRootElement.SaveToPart(OpenXmlPart openXmlPart) in DocumentFormat.OpenXml.OpenXmlPartRootElement.Save()

    this exception is not thrown for every docx file processed by my program, but is repeatedly produced on certain file (the cause is not clear). anyway, the processed docx file loads normally in Word.

    Someone knows the possible cause?



    I recently updated the SDK to August 2009 CTP, might it be a bug of the new Autosave feature?



    And later i've shrunk the range of the exception to the following code, where the exact line that causes the exception seems to be an InsertAfterSelf() methed which is used in processing a footnotes part, while the same procedure was used there before for processing the main document part with no exception occured at all (as is rather weird).

    targetRoot.Save(); //-- saved OK
    cxBlock.InsertAfterSelf(derivedCustomElement);
    targetRoot.Save(); //-- Exception Thrown!!
    Welcome to visit my Blog:xiaoyuvax.spaces.live.com Follow me on Twitter: twitter.com/xiaoyuvax
  • The cause is that such Class as Footnote(or Endnote) with type="Separater" shall not be modified, or they may cause the problem above,despite word parsing it without any prompt by just ignoring the modified node.
    Welcome to visit my Blog:xiaoyuvax.spaces.live.com Follow me on Twitter: twitter.com/xiaoyuvax
Page 1 of 1 (2 items)