[IronPython] Problem with com object
dfugate at microsoft.com
Wed Feb 10 08:48:04 PST 2010
Offhand, the Python snippet you've sent appears fine. When you run this against IronPython, can you pass the "-X:ExceptionDetail" flag to ipy.exe and send back the results?
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Alberto Fernandez
Sent: Wednesday, February 10, 2010 2:59 AM
To: users at lists.ironpython.com
Subject: [IronPython] Problem with com object
Please excuse me if what I'm asking is trivial but I'm just starting with anything .net related and ironpython. I have a little experience programing c++ and python but I'm not a professional programmer.
What I'm trying to do is write a macro for a program through its com connectivity. The reason is that I do not know much (and I don't like what I know) about VBA. I also would like to reuse code that I've written in pyhton.
The problem that I have is that I get an error message "HRESULT E_FAIL" when I try to do anything with the generated object. However, I can see that the application launches. In fact, what I think is the equivalent code in VB seems to work.
Dim catia As INFITF.Application
catia = CreateObject("CATIA.Application")
'catia = System.Runtime.InteropServices.Marshal.getActiveObject("CATIA.Application")
Console.Write(" Press any key to continue . . . ")
The code that I'm using in ironpython is:
t = System.Type.GetTypeFromProgID("CATIA.Application")
CATIA = System.Activator.CreateInstance(t)
I can see the application starting too but as soon as I try to probe it or do something I get the error.
I'm sure missing something but I do not know what.
By the way I'm using sharpDevelop as IDE. It is one of the reason I would like to go this route, it facilitates me a lot any GUI that I may want to include.
I've been fighting with this for two days. I can connect and work using win32com in regular python but I'm not able to go that route with ironpython either.
thank you a lot for your time.
Users mailing list
Users at lists.ironpython.com
More information about the Users