在c#中调用ironpython会得到一个UnBoundNameException

本文关键字:UnBoundNameException 一个 调用 ironpython | 更新日期: 2023-09-27 18:06:28

问题是;

   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文件创建的:

# -*- coding: utf-8 -*- 
import RTDBBase 
from RTDBBase import *
Group1 = PRTDBTagGroup("Group1")

,为什么?

在c#中调用ironpython会得到一个UnBoundNameException

OK,如果要执行Group1.Collection1。Tag1 =10,我应该这样做:

  ScriptSource source = mScriptScope.Engine.CreateScriptSourceFromString("Group1.Collection1.Tag1 =10", SourceCodeKind.Statements);
  source.Execute(mScriptScope);
相关文章:
  • 没有找到相关文章