My application uses IronPython for users to run scripts. One such script is used for setting the members of a structure. My Structure is as follows:
[StructLayout(LayoutKind.Sequential)]
public struct Data
{
int a;
int b;
}
I have declared a class level public object for this structure like:
public Data data = new data();
I am setting the data
object as the scope variable for IronPython:
scope.SetVariable("data", data);
In the python script, I am setting the variables a
and b
:
data.a = 5
data.b = 10
But the variables are not changing in the C# code. I have noticed that if I use a normal integer or any other type, those variables are setting.
Is there some issue with using structures? How can I set the C# structure members from IronPython?