经典 ASP 测试服务器是否可以创建对象

S..*_*S.. 1 asp-classic

使用此代码:

Dim xmlDOM
Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")    
Run Code Online (Sandbox Code Playgroud)

如何测试 CreateObject 函数是否成功?

tgo*_*sch 5

如果它不起作用,您可能会收到错误消息。否则,您可以使用以下代码:

Dim xmlDOM
'dont fail on error'
On Error Resume Next
Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
On Error GoTo 0 'turn error handling off again'

If Not xmlDOM Is Nothing Then
   'not null: it worked'
Else
   'xmlDOM is nothing.  It was not able to create the object. ' 
   'Check create permissions in COM+'
End If
Run Code Online (Sandbox Code Playgroud)