I believe Brian's assessment is correct. The easiest way to handle this is to use pywin32's pythoncom module to set the threading model. You can find a sample of how to do that here:
http://www.ironpython.info/index.php/Using_the_WebBrowser_Widget
In the sample, the WebBrowser widget (which uses ActiveX underneath) is embedded in a form. By invoking pythoncom.CoInitialize(), we set the threading model to STA which prevents the program from crashing when it initializes the form.
--- On Mon, 12/1/08, Brian Lloyd <brian.lloyd at revolutionhealth.com> wrote:
From: Brian Lloyd <brian.lloyd at revolutionhealth.com>
Subject: Re: [Python.NET] Cannot initialize OLE
To: "Daniele Esposti" <expo at expobrain.net>, pythondotnet at python.org
Date: Monday, December 1, 2008, 1:45 PM
This probably has to do with the threading model being auto-magically
set for you when the CLR is cranked up, absent any prior initialization.
The managed version of python.exe is able to set the threading model
(to MTA I believe) because it is a managed executable. When you import
clr via the standard python.exe, you are probably getting the default
model (STA). I could have those backwards - its been a while ;)
If you are using the win32com extensions, you might be able to import
those, set the threading model for the process, then import clr. Not
sure if that will work, but its worth a shot. I don't think there is
any way to change the threading model once it's set.
-Brian
On 12/1/08 8:53 AM, "Daniele Esposti" <expo at expobrain.net>
wrote:
> Hi all,
>> if I run my application (a wxPython frame with a wx.Activex Flash
> component) with the python.exe in pythonnet folder its work like expected.
> Instead, if I run my application with the standard Python interpreter,
> with clr.pyd in DLLs folder and Python.Runtime.dll in the same
> interpreter folder, I get a warnings says Cannot initialize OLE and the
> ActiveX is locked.
> I'm using Python 2.5.2 on a Windows XP SP3 machine, PythonNet
> 2.0-alpha2-clr2.0 compiled with VisualStudio Express 2008.
>> Have I missing something ? Only clr.pyd and Python.Runtime.dll are
> needed or there are others resources to copy in Python interpreter folder
?
>> Thanks in advance
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org>http://mail.python.org/mailman/listinfo/pythondotnet
--------------------------------
Brian Lloyd 540.845.2975
brian.lloyd at revolutionhealth.com
_________________________________________________
Python.NET mailing list - PythonDotNet at python.orghttp://mail.python.org/mailman/listinfo/pythondotnet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20081201/4d94d916/attachment.htm>