[IronPython] Getting type error when calling a .NET DLL interface.

Curt Hagenlocher curt at hagenlocher.org
Mon May 4 14:50:05 PDT 2009

In a statically-typed language like C#, if you have a reference to an
"object", you need to tell the compiler that this object is really a "Foo"
in order to use any of Foo's methods with the object. The compiler generates
whatever code is necessary to cast the variable to a Foo and will then allow
you to use any of Foo's public methods with the object.  (In a
strongly-typed language like C#, the typecast may also throw an exception if
the object isn't really a Foo.)
Variables don't have types in a dynamically-typed language like Python, so
the idea that you can cast the variable to another type simply doesn't
exist. Instead, when you call a method by a particular name, the call is
dispatched at runtime based on whatever form of method resolution is
appropriate for that object.

Side note: for .NET, unless some kind of remoting comes into the picture,
all references to an object see the entire object.  This is in contrast to
COM, where you never really see more than one interface at a time on the

On Mon, May 4, 2009 at 2:16 PM, Max Barry <max at ford-consulting.com> wrote:

> Thanks Dave that seemed to work. Can you tell me why this is the case? I
> ran the code in python for .NET and it work correctly. I would expect to
> have implemented the interface in this way in order to use it.
> Thanks,
> Max
> _______________________________________________
> 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://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20090504/ed60ade6/attachment.htm>

More information about the Users mailing list