win32com, string array --> Type mismatch?

Discussion in 'Python' started by Harry Pehkonen, Aug 8, 2003.

  1. I'm running WRQ's Reflection telnet client
    (win32com.client.Dispatch("Reflection2.Session")). It appears I can
    only do late binding. There is one method that takes a ``string
    array,'' and fails with:

    Traceback (most recent call last):
    File "<interactive input>", line 1, in ?
    File "Reflection.py", line 549, in goto_switch
    result = self.connection.WaitForStrings(waitfor_strngs)
    File "Reflection.py", line 399, in WaitForStrings
    options)
    File "<COMObject Reflection2.Session>", line 2, in WaitForStrings
    com_error: (-2147352571, 'Type mismatch.', None, 1)

    I've tried providing lists and tuples of strings, lists and tuples of
    unicode strings.

    makepy -i reports:

    Warning - could not load registered typelib

    Without the -i, it creates CLSID
    0DE5A6C0-4B0D-101B-AC7B-04021C007002.py, but when I run the telnet
    client, COM Browser says it's F29799A0-4B0C-101B-AC7B-04021C007002
    (off a bit). The 0DE...py module mentions this CLSID F29...

    I tried renaming and importing the 0DE...py file, but I still get the
    Type mismatch.

    In short, is there something specific I need to do in order to pass a
    ``string array'' from Python to a COM server when I'm (I think) stuck
    with late binding?

    Thanks!
    Harry.

    PS. Please reply to this group as I get a ton of spam.
    Harry Pehkonen, Aug 8, 2003
    #1
    1. Advertising

  2. Harry Pehkonen

    Roger Upole Guest

    I've run into the same problem with Reflection. This is what I do to get
    around it:
    import win32com.client
    ###win32com.client.gencache.EnsureDispatch('Reflection2.Application',0)
    ###only need to do above once
    ra=win32com.client.Dispatch('Reflection2.Application')
    m=win32com.client.gencache.GetModuleForProgID('Reflection2.Application')
    r=m.Application(ra)
    r.Visible=1
    r.WaitForStrings(('xxxxx','yyyyyy'),0,1)
    I'm probably using an older version of Reflection than you are (there is
    no
    Session object) but the same principles should apply.
    hth
    Roger

    "Harry Pehkonen" <> wrote in message
    news:...
    > I'm running WRQ's Reflection telnet client
    > (win32com.client.Dispatch("Reflection2.Session")). It appears I can
    > only do late binding. There is one method that takes a ``string
    > array,'' and fails with:
    >
    > Traceback (most recent call last):
    > File "<interactive input>", line 1, in ?
    > File "Reflection.py", line 549, in goto_switch
    > result = self.connection.WaitForStrings(waitfor_strngs)
    > File "Reflection.py", line 399, in WaitForStrings
    > options)
    > File "<COMObject Reflection2.Session>", line 2, in WaitForStrings
    > com_error: (-2147352571, 'Type mismatch.', None, 1)
    >
    > I've tried providing lists and tuples of strings, lists and tuples of
    > unicode strings.
    >
    > makepy -i reports:
    >
    > Warning - could not load registered typelib
    >
    > Without the -i, it creates CLSID
    > 0DE5A6C0-4B0D-101B-AC7B-04021C007002.py, but when I run the telnet
    > client, COM Browser says it's F29799A0-4B0C-101B-AC7B-04021C007002
    > (off a bit). The 0DE...py module mentions this CLSID F29...
    >
    > I tried renaming and importing the 0DE...py file, but I still get the
    > Type mismatch.
    >
    > In short, is there something specific I need to do in order to pass a
    > ``string array'' from Python to a COM server when I'm (I think) stuck
    > with late binding?
    >
    > Thanks!
    > Harry.
    >
    > PS. Please reply to this group as I get a ton of spam.
    Roger Upole, Aug 9, 2003
    #2
    1. Advertising

  3. "Roger Upole" <> wrote in message news:<>...
    > I've run into the same problem with Reflection. This is what I do to get
    > around it:
    > import win32com.client
    > ###win32com.client.gencache.EnsureDispatch('Reflection2.Application',0)
    > ###only need to do above once


    That's very interesting -- for me, it produces yet another CLSID:

    KeyError: '{1396DDA0-4B0D-101B-AC7B-04021C007002}'

    I got the above when trying to EnsureDispatch for Reflection2.Session.
    Trying to do the same for Reflection2.Application produces an
    ``invalid class string.'' I also get that with
    Dispatch("Reflection2.Application") :C

    > ra=win32com.client.Dispatch('Reflection2.Application')
    > m=win32com.client.gencache.GetModuleForProgID('Reflection2.Application')


    I seem to get None from GetModuleForProgID. I also tried
    GetModuleForCLSID with all of three CLSID's -- all produce:

    >>> type(m)

    <type 'NoneType'>

    > r=m.Application(ra)
    > r.Visible=1
    > r.WaitForStrings(('xxxxx','yyyyyy'),0,1)
    > I'm probably using an older version of Reflection than you are (there is
    > no
    > Session object) but the same principles should apply.


    Mine is version 8.0.5. The documentation just says you get more
    visual basic support, and possible faster scripts with the Session
    object than Application. I'd say stick with the older one ;D

    Thanks, Roger, for your reply. That method is still dead in the water
    for me, but I'm thrilled to learn more about win32all!

    I have that method wrapped nicely, so I'll just make some work-arounds
    for now, and fix it later if possible.

    Thanks again!
    Harry.
    Harry Pehkonen, Aug 11, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Sargent

    Type mismatch: '[string: ""]'

    Mark Sargent, Nov 2, 2003, in forum: ASP General
    Replies:
    10
    Views:
    224
    Mark Sargent
    Nov 5, 2003
  2. Replies:
    4
    Views:
    192
  3. Type mismatch: '[string: ""]'

    , Dec 14, 2005, in forum: ASP General
    Replies:
    2
    Views:
    144
    Kyle Peterson
    Dec 14, 2005
  4. Snow
    Replies:
    3
    Views:
    218
    Firas S Assaad
    Oct 27, 2006
  5. programmingzeal
    Replies:
    0
    Views:
    1,111
    programmingzeal
    May 6, 2012
Loading...

Share This Page