Saturday, August 16, 2008

Calling IronPython Functions from VB.NET

Maurice de Beijer is a VB.NET developer from the Netherlands. He has a particular interest in the Workflow Foundation and is interested in exploring it from IronPython. He has started his exploration by looking at creating Python functions and using them from VB.NET via the IronPython hosting API. As most examples of embedding IronPython are in C#, it is nice to see some examples in Visual Basic.NET.
He shows several code examples and is using IronPython 2.0 Beta 3. His code creates a class from VB.NET and then imports this into Python code. The Python subclasses the VB.NET class, and he can then pull this class out of the IronPython execution scope because he knows what type it is.

This is one of the ways of solving the 'type problem' when working with dynamic languages from statically typed languages like C# and VB.NET. Using dynamic operations exposed by the IronPython runtime you can then create instance of this Python class. It's actually easier than I made it sound; Maurice's example is very clear.

No comments:

Post a Comment

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