[IronPython] Unable to cast object of type 'IronPython.Runtime.Types.OldClass' to type 'IronPython.Runtime.Types.DynamicType'

Mike Raath raathm at gmail.com
Fri Jul 14 09:17:38 CEST 2006


OK - I've broken it down to its simplest form. It looks like there's a
problem importing the minidom class.

If you create a module TestModule.py containing the following code:

Python Code
==========
import xml.dom.minidom

class TestClass:
    pass


and then try to import this class you will see this error.

My C# code is as follows:
====================
            PythonEngine engine = new PythonEngine();

            engine.AddToPath("C:\\Python24\\lib");
            engine.AddToPath
("C:\\Temp\\IronPythonTest\\IronPythonTest\\Python\\");
            engine.Execute("from TestModule import TestClass");


Mike


On 7/13/06, Martin Maly <Martin.Maly at microsoft.com> wrote:
>
>  However, that said, in Beta 9, the OldClass is no longer a DynamicType,
> which explains the exception itself. To find out what you need to change in
> your code is something that we'll need more info for.
>
>
>
> For example, the exception can come from anywhere in the Module body
> (during import, the module body gets executed – unless the module has been
> already imported). Since I don't get exception when executing "from Module
> import Class", I suspect that this is what may be the case. The call stack
> for the exception could help find out what line in your module code is
> throwing.
>
>
>
> M.
>
>
>  ------------------------------
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Martin Maly
> *Sent:* Thursday, July 13, 2006 8:09 AM
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] Unable to cast object of type '
> IronPython.Runtime.Types.OldClass' to type '
> IronPython.Runtime.Types.DynamicType'
>
>
>
> To help you, we will need more information about your use of the Python
> Engine. The simple case of executing "from Module import Class" does work so
> we need to know more to find out what the problem may be.
>
>
>
> Thanks
>
> Martin
>
>
>  ------------------------------
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Mike Raath
> *Sent:* Thursday, July 13, 2006 1:41 AM
> *To:* Discussion of IronPython
> *Subject:* [IronPython] Unable to cast object of type '
> IronPython.Runtime.Types.OldClass' to type '
> IronPython.Runtime.Types.DynamicType'
>
>
>
> Hi
>
> Having tried to switch over to beta 9, and changing my generic Evaluate<T>
> references to EvaluateAs<T>, I get a runtime error on an import statement
> which works under beta 8. The exception is as is detailed in the message
> above, and is from a statement like
> engine.Execute("from Module import Class);
>
> The Module and Class definitions are custom - and as i say this statement
> works under beta 8.
>
> Do you require more information or do I need to make a further change to
> my code to get it to work?
>
> Thanks,
> Mike
>
> _______________________________________________
> 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/20060714/c4114993/attachment.html>


More information about the Ironpython-users mailing list