IronPython returns the wrong type when using a class in a class library

Can someone recommend a workaround for this Ironpthon error?

I have a class contained inside an external class library. I use this class inside a built-in instance of ironpython. When a class is pulled out of scope by my C # application, the classes do not seem to match!

My python script:

import sys
import clr
from ExternalAssembly import *
from IronPythonBug import *

internalClass = InternalClass("internal")
externalClass = ExternalClass("external")

My C # app:

internalClass = scope.GetVariable("internalClass");
externalClass = scope.GetVariable("externalClass");

if (internalClass is InternalClass)
    Console.WriteLine("IternalClass matches");
else
    Console.WriteLine("Error: InternalClass does not match");

if (externalClass is ExternalClass)
    Console.WriteLine("ExternalClass matches");
else
    Console.WriteLine("Error: ExternalClass does not match");

Console output:

IternalClass matches
Error: ExternalClass does not match

Feel free to download a project that illustrates this error: http://www.virtual-chaos.net/zip/IronPythonBug.zip

+3
source share
2 answers

CLR. Assembly.LoadFile - , . Assembly.LoadFile typeof (ExternalClass)..

+6

externalClass.GetType() .

InternalClass , .

0

Source: https://habr.com/ru/post/1755903/


All Articles