[IronPython] how do i get the ScriptModule for __main__

Iain Cartwright iaincartwright at kromestudios.com
Tue Jul 17 07:45:17 CEST 2007

I have built a C# class library based on RichTextBox as a drop-in 
ironpython (2.0A2) console for windows forms apps.

I would like to access the __main__  module from my C# code via an 
IScriptModule but i cannot find a way to do this.

I have a ScriptModule that represents the host applications object model 
created thus:

    _pyEngine.CreateModule("ObjectModel", appObjectModel, 

I tried to retrieve __main__ through the 
PythonEngine.DefaultModuleContext and through:

ScriptDomainManager.CurrentManager.TryGetScriptModule("__main__", out 

but no luck.  I'm  sure I'm missing something obvious - any ideas?



iain cartwright
Technical Director
Krome Studios Melbourne
Phone: +61 3 9867 0753
Fax: +61 3 9867 0800

This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

More information about the Ironpython-users mailing list