【发布时间】:2010-10-11 04:43:00
【问题描述】:
我有以下 C# 代码将其编译成 MyMath.dll 程序集。
namespace MyMath {
public class Arith {
public Arith() {}
public int Add(int x, int y) {
return x + y;
}
}
}
我有以下 IronPython 代码来使用这个对象。
import clr
clr.AddReferenceToFile("MyMath.dll")
import MyMath
arith = Arith()
print arith.Add(10,20)
当我使用 IronPython 运行此代码时,我收到以下错误。
回溯(最近一次通话最后): 文件 ipycallcs,行未知,在 Initialize NameError:名称“Arith”未定义可能出了什么问题?
添加
arith = Arith() 应该是 arith = MyMath.Arith()
【问题讨论】:
-
不应该是arith = MyMath.Arith()吗?
-
@Mark :是的,这就是问题所在,谢谢。
-
要修复 IronPython 中的常见错误,试试这个Beginning IronPython
标签: c# python ironpython