[IronPython] how do i get the ScriptModule for __main__

Stefan Dobrev stefan.dobrev at gmail.com
Tue Jul 17 11:16:35 CEST 2007

You have to create the current main module with:

ScriptDomainManager.CurrentManager.CreateModule( "__main__" );

Hope this helps,
Stefan Dobrev

2007/7/17, Iain Cartwright <iaincartwright at kromestudios.com>:
> 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,
> ModuleOptions.PublishModule);
> I tried to retrieve __main__ through the
> PythonEngine.DefaultModuleContext and through:
> ScriptDomainManager.CurrentManager.TryGetScriptModule("__main__", out
> _moduleMain);
> but no luck.  I'm  sure I'm missing something obvious - any ideas?
> Thanks
> iain
> --
> _____________________________________
> 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.
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070717/bf2aaa41/attachment.html>

More information about the Ironpython-users mailing list