Sunday, October 28, 2007

IronPython 2, 'with' and COM

IronPython 2 targets Python 2.5, which means that the with statement is available. This is convenient because the currently released version of IronPython 2 there is a memory leak that keeps COM objects alive after they are used.

This bug is fixed in the IronPython source code control, but in the meantime a Japanese blogger has a workaround that uses 'with' and calls Marshal.ReleaseComObject - his fantastically nested example is for Excel Interop.
His blog has some other interesting IronPython stuff, including this example of Excel 2007 interop that creates a spreadsheet from a bitmap!

No comments:

Post a Comment

Note: only a member of this blog may post a comment.