Jump to content

Scripting.Dictionary error - Variable must be of type "Object"


Recommended Posts

When I try this on my PC it is fine, but when I try it on a XP VM it fails. The VM has xplite installed and fairly much everything is stripped off.

What does Scripting.Dictionary need in order to work?

$o = ObjCreate("Scripting.Dictionary")
$o.Add ("test", "Test")

test.au3 (2) : ==> Variable must be of type "Object".:
$o.Add ("test", "Test")
$o^ ERROR
Link to comment
Share on other sites

You must have those objects registered. Since you said its a lite version, then you probably don't.

Have you tried using a custom error handler?

For example:

$oIE=ObjCreate("InternetExplorer.Application.1")   ; Create Internet Explorer application

Global $g_eventerror = 0   ; to be checked to know if com error occurs. Must be reset after handling.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")   ; Initialize a COM error handler

$oIE.UnknownMethod   ; Deliberately call an undefined method

If $g_eventerror then
    $g_eventerror = 0
  Msgbox (0,"AutoItCOM test","Test passed: We got an error number: " & @error)
Else
  Msgbox (0,"AutoItCOM test","Test failed!")
Endif

Exit

; This is my custom defined error handler
Func MyErrFunc()

  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"    & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "       & @TAB & hex($oMyError.number,8)  & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "       & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile     & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
            
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    
    $g_eventerror = $err ; to check for after this function returns
Endfunc

Cheers,

Brett

:D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...