简体   繁体   中英

Invoke ironpython in c# got an UnBoundNameException

The problem is;

   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 is created from .py file:

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

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

and why?

OK,if want to Excute Group1.Collection1.Tag1 =10,I should do this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM