Troubleshooting COM error after upgrade to .NET 6
Martin Wiboe <[email protected]> Tue, 14 May 2024 14:31:15 +0200
| Newsgroups | gmane.comp.python.windows |
|---|---|
| Message-ID | <CABg1pRkfoZ-TY+EX63yfGTcjVPaB0CxMyQhog=_9FFq9tnQEnQ@mail.gmail.com> |
--===============9005782409022999080==
Content-Type: multipart/alternative; boundary="0000000000003eeaa40618692ed6"
--0000000000003eeaa40618692ed6
Content-Type: text/plain; charset="UTF-8"
Hello
I'm working with an application developed in .NET Framework, but recently
migrated to .NET 6.
The application provides a number of COM components, and I am unable to
call them from python after the migration. Our other COM clients (Excel and
FORTRAN) work as before.
My code is as follows:
import os
import win32com.client
# Declaring objects
fluid = win32com.client.Dispatch("OurProduct.Object")
This fails with the stack trace below:
Traceback (most recent call last):
File
"C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32com\client\dynamic.py",
line 84, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\Desktop\OurProduct\Python\Flash_Sample.py", line 13,
in <module>
fluid = win32com.client.Dispatch(" OurProduct.Object ")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32com\client\__init__.py",
line 118, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,
userName, clsctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32com\client\dynamic.py",
line 104, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32com\client\dynamic.py",
line 86, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.com_error: (-2147467262, 'No such interface supported', None,
None)
It's not apparent to me what the error could be. The component does
implement IDispatch.
Do you have any suggestions on how to troubleshoot this further, or what
the problem could be?
Thanks in advance,
Martin
--0000000000003eeaa40618692ed6
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Hello</div><div><br></div><div>I'm working with a=
n application developed in .NET Framework, but recently migrated to .NET 6.=
</div><div>The application provides a number of COM components, and I am un=
able to call them from python after the migration. Our other COM clients (E=
xcel and FORTRAN) work as before.</div><div><br></div><div>My code is as fo=
llows:</div><div style=3D"margin-left:40px"><br></div><div style=3D"margin-=
left:40px">import os<br>import win32com.client<br><br># Declaring objects<b=
r>fluid =3D win32com.client.Dispatch("OurProduct.Object")</div><d=
iv><br></div><div>This fails with the stack trace below:<br></div><div><br>=
</div><div style=3D"margin-left:40px">Traceback (most recent call last):</d=
iv><div style=3D"margin-left:40px">=C2=A0 File "C:\Users\User\AppData\=
Local\Programs\Python\Python312\Lib\site-packages\win32com\client\dynamic.p=
y", line 84, in _GetGoodDispatch<br>=C2=A0 =C2=A0 IDispatch =3D python=
com.connect(IDispatch)<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>pywintypes.com_error: (-2147221021, =
'Operation unavailable', None, None)<br><br>During handling of the =
above exception, another exception occurred:<br><br>Traceback (most recent =
call last):<br>=C2=A0 File "C:\Users\User\Desktop\OurProduct\Python\Fl=
ash_Sample.py", line 13, in <module><br>=C2=A0 =C2=A0 fluid =3D =
win32com.client.Dispatch("
OurProduct.Object
")<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^^^^^^^^^^^^^^^^^^^^^^=
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>=C2=A0 File "C:\Users\User\AppData=
\Local\Programs\Python\Python312\Lib\site-packages\win32com\client\__init__=
.py", line 118, in Dispatch<br>=C2=A0 =C2=A0 dispatch, userName =3D dy=
namic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>=
=C2=A0 File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib=
\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispa=
tchAndUserName<br>=C2=A0 =C2=A0 return (_GetGoodDispatch(IDispatch, clsctx)=
, userName)<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^^^^^^^^^^^^^^^^^^=
^^^^^^^^^^^^^^^^^<br>=C2=A0 File "C:\Users\User\AppData\Local\Programs=
\Python\Python312\Lib\site-packages\win32com\client\dynamic.py", line =
86, in _GetGoodDispatch<br>=C2=A0 =C2=A0 IDispatch =3D pythoncom.CoCreateIn=
stance(<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^^^^^^^^=
^^^^^^^^^^^^^^^^^^^<br>pywintypes.com_error: (-2147467262, 'No such int=
erface supported', None, None)</div><div><br></div><div>It's not ap=
parent to me what the error could be. The component does implement IDispatc=
h.<br></div><div>Do you have any suggestions on how to troubleshoot this fu=
rther, or what the problem could be?</div><div><br></div><div>Thanks in adv=
ance,</div><div>Martin<br></div></div>
--0000000000003eeaa40618692ed6--
--===============9005782409022999080==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32
--===============9005782409022999080==--