2013-03-28 32 views
0

问题是;在C#中调用Ironpython得到一个UnBoundNameException

# -*- coding: utf-8 -*- 

import RTDBBase 
from RTDBBase import * 
Group1 = PRTDBTagGroup("Group1") 

为什么:

var instance = mScriptScope.GetVariable("Group1"); //here I can get the instance named "Group1" ,type is IronPython.Runtime.Types.OldInstance 
    mScriptScope.Engine.Execute(context);//but here I excute Group1.Collection1.Tag1 =10 throw an UnBoundNameException : global name 'Group1' is not defined 

mScriptScope从.py文件产生的?

+0

请尽量避免过于广泛的代码示例和注释。滚动并不会让阅读变得很容易。 – 2013-03-28 14:57:12

回答

0

OK,如果想EXCUTE Group1.Collection1.Tag1 = 10,我应该这样做:

ScriptSource source = mScriptScope.Engine.CreateScriptSourceFromString("Group1.Collection1.Tag1 =10", SourceCodeKind.Statements); 
    source.Execute(mScriptScope);