Error when loading valid Windows-1252 document “System error: -2146697210”

后端 未结 1 1783
攒了一身酷
攒了一身酷 2020-12-02 02:17

Somehow, sometimes the code below generates an error when loading valid Windows-1252 XML.

It fails on Windows XP Professional x86 SP3 using MSXML6.
It succeeds o

相关标签:
1条回答
  • 2020-12-02 02:54

    The behaviour depends on which version of the MSXML6.DLL you have installed.

    To reproduce this better, I created another file abnormal.xml, in addition to the normal.xml from the question.

    File dump abnormal.xml:

    000000: 3C 3F 78 6D 6C 20 76 65  72 73 69 6F 6E 3D 22 31 <?xml version="1
    000010: 2E 30 22 20 73 74 61 6E  64 61 6C 6F 6E 65 3D 22 .0" standalone="
    000020: 79 65 73 22 3F 3E 3C 52  4F 57 20 43 69 74 79 3D yes"?><ROW City=
    000030: 22 E0 22 2F 3E 0D 0A                             "."/>..
    

    File abnormal.xml:

    <?xml version="1.0" standalone="yes"?><ROW City="à"/>
    

    File dump normal.xml:

    000000: 3C 3F 78 6D 6C 20 76 65  72 73 69 6F 6E 20 3D 20 <?xml version =
    000010: 22 31 2E 30 22 20 65 6E  63 6F 64 69 6E 67 3D 22 "1.0" encoding="
    000020: 57 69 6E 64 6F 77 73 2D  31 32 35 32 22 3F 3E 3C Windows-1252"?><
    000030: 52 4F 57 20 43 69 74 79  3D 22 E0 22 2F 3E 0D 0A ROW City="."/>..
    

    File normal.xml:

    <?xml version = "1.0" encoding="Windows-1252"?><ROW City="à"/>
    

    The behaviour I expect is that:

    1. abnormal.xml fails, because it does not specify an encoding, but contains a character with the high-bit set
    2. normal.xml succeeds, as it conains a single-byte encoding supporting high-bit characters, so characters with high-bit set are allowed

    These are the observed scenarios:

    MSXML6 FAILURE:

    reason: System error: -2146697210.
    errorCode: -2146697210
    url: file:///C:/My%20Dropbox/XMLEOSErrorTest/Abnormal.xml
    
    reason: System error: -2146697210.
    errorCode: -2146697210
    url: file:///C:/My%20Dropbox/XMLEOSErrorTest/Normal.xml
    

    MSXML6 SUCCESS:

    reason: An invalid character was found in text content.
    
    errorCode: -1072896760
    url: file:///C:/My%20Dropbox/XMLEOSErrorTest/Abnormal.xml
    srcText: <?xml version="1.0" standalone="yes"?><ROW City="
    line: 1
    linepos: 50
    filepos: 49
    

    This is an overview of what versions fail.
    The names of the DLL's between parentheses are from their version information.

    failure; XP Professional SP3:
    msxml6.dll       version 6.20.1099.0  (MSXML 6.0 SP2)
    msxml6r.dll      version 6.0.3883.0   (XML Resources)
    
    success; Windows 7 Ultimate x64 SP1:
    msxml6.dll       version 6.30.7600.16385  (MSXML 6.0 SP3)
    msxml6r.dll      version 6.30.7600.16385
    msxml6r.dll.mui  version 6.30.7600.16385
    
    success; XP Professional SP3:
    msxml6.dll       version 6.20.1103.0  (MSXML 6.0 SP3)
    msxml6r.dll      version 6.0.3883.0   (XML Resources)
    

    Observations:

    • Automatic Windows Update and Microsoft Update will not update MSXML6.DLL to the latest version on Windows XP SP3.
    • There is no MSXML6 SP3 for Windows XP.
    • The latest version is in fact 6.20.2003.0 for Windows XP SP2 and can be obtained at http://support.microsoft.com/kb/973686 (it does not install on Windows XP SP3).
    • The 6.20.1103.0 version of MSXML6.DLL for Windows XP SP3 can be obtained at http://support.microsoft.com/kb/973687 (direct download for XP SP3)
    • Microsoft has very little information on their site about this: http://www.google.com/search?q=msxml6+%226.20.1099.0%22+%226.20.1103.0%22+site:microsoft.com
    • Searching only for 6.20.1103.0 does not reveal much more: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=msxml6+%226.20.1103.0%22+site:microsoft.com
    • This gives the best search results: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=msxml6+%226.20.1103.0%22#sclient=psy&num=10&hl=en&q=msxml6+%226.20.1099.0%22+%226.20.1103.0%22

    So: when doing MSXML6 work, first put in a check that you indeed have the latest MSXML6.DLL for your target Windows version.

    --jeroen

    0 讨论(0)
提交回复
热议问题