vb.net MSXML“系统找不到指定的资源”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4041687/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:06:32  来源:igfitidea点击:

MSXML "The system cannot locate the resource specified"

vb.netmsxml

提问by Macros

I have a function which uses MSXML to post an XML document which yesterday started failing despite no change being made to the code. The function is as follows:

我有一个函数,它使用 MSXML 发布一个 XML 文档,尽管没有对代码进行任何更改,但昨天该文档开始失败。功能如下:

Public Function PostFile(ByVal address As String, ByVal data As Byte()) As xmldocument
    Dim xmlHTTP As New MSXML2.XMLHTTP
    Dim response As New XmlDocument

    Dim xmlDoc As New MSXML2.DOMDocument

    Try
        xmlDoc.load(data)
        xmlHTTP.open("post", address, False)
        xmlHTTP.send(xmlDoc)

        If xmlHTTP.responseXML.xml <> String.Empty Then
            response.LoadXml(xmlHTTP.responseXML.xml)
            Return response
        Else
            Dim result As String = "<NO_Response><Error>the post succeeded to " + address + " but there was no responce returned</Error><Hint>Check FireWall Settings</Hint></NO_Response>"
            response.loadxml(result)
            Return response
        End If

    Catch ex As Exception
        'Error logging code removed

    End Try
    Return Nothing
End Function

The XML document and the address being passed in are both correct - the line which causes the error is xmlHTTP.send(xmlDoc). I have tried this on 2 different machines with the same error each time and have also tried resinstalling MSXML3, with no success.

XML 文档和传入的地址都是正确的 - 导致错误的行是xmlHTTP.send(xmlDoc). 我已经在 2 台不同的机器上尝试过,每次都出现相同的错误,也尝试过重新安装 MSXML3,但没有成功。

The exception thrown is:

抛出的异常是:

InnerException: Nothing 
Message:        "The system cannot locate the resource specified. "
Source:         "msxml3.dll"    
StackTrace:     "   at MSXML2.XMLHTTPClass.send(Object varBody)    at comms.HTTPHandler.PostFile(String address, Byte[] data) in D:\SCC\Main\Sender\Http.vb:line 42"

回答by Macros

It turned out to be a networking issue - I didn't suspect this at first as the error was raised so quickly which didn't suggest an issue with the endpoint. The problem was with a rule which had been added (don't ask why) to the firewall preventing communication with the destination address.

结果证明是网络问题 - 我一开始并没有怀疑这一点,因为错误出现得如此之快,这并没有表明端点存在问题。问题在于已添加(不要问为什么)到防火墙的规则阻止了与目标地址的通信。

回答by TeflonDon

If you are just processing the xml or dtd is offline, you can use: xmlDoc.resolveExternals = False

如果你只是处理xml或者dtd离线,可以使用:xmlDoc.resolveExternals = False