[python-win32] win32com.client.Dispatch problem

Amit Upadhyay upadhyay at gmail.com
Fri Jun 24 13:26:37 CEST 2005


Hi,

So here is my problem, I have to implement a com server, that would be used 
by DotNet application, which can not work with late binding (apparently they 
don't have CreateObject of VB). So i am following the approach suggested by 
http://starship.python.net/crew/theller/ctypes/sum_sample.html, and things 
worked for a while but I am getting weird results now. Weird: python stops 
working, just shows the prompt. 

Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
>>> w = win32com.client.Dispatch("ctypes.asd")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, 
in
Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
lsctx)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in 
_
GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in 
_
GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
D_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
>>> w = win32com.client.Dispatch("ctypes.SumObject")
>>> w
>>> w
>>> 1+2
>>>

Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
>>> w = win32com.client.Dispatch("PythonDemos.Utilities")
>>> w
<COMObject PythonDemos.Utilities>
>>> dir(w)
['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', 
'__A
ttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', 
'__g
etitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', 
'__rep
r__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', 
'_fin
d_dispatch_type_', '_get_good_object_', '_get_good_single_object_', 
'_lazydata_'
, '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', 
'_print_details_
', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']
>>> w.SplitString("asd")
(u'asd',)
>>> w = win32com.client.Dispatch("ctypes.SumObject")
>>> w.get(2,3)
>>> w
>>> 1+2
>>>

Does it sound familiar? A bug in win32com.client.Dispatch or should I be 
looking at my com server code [which is almost what is presented in 
sum_sample page I linked above? GUID conflict? I am stuck, please help. 

TIA,

-- 
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9820-859-701
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/attachment.htm
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sum.idl
Url: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/sum.diff
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sum_p.py
Url: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/sum_p.diff
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sumserver.py
Url: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/sumserver.diff


More information about the Python-win32 mailing list