MSScriptControl.ScriptControlClass - access a sub-object of the main object

980 views Asked by At

I want do add a huge object with lots of sub-objects to a ScriptControlClass. While accessing these sub-classes I get an error that the object is null or no object

MSScriptControl.ScriptControlClass js = new MSScriptControl.ScriptControlClass();
js.AllowUI = false;
js.Language = "JScript";
js.Reset();
js.AddObject("MyObject", myObject, false);

[ComVisible(true)]
class AAA
{
    public BBB Bbb { get; set; } 
}

class BBB
{
    public CCC Ccc { get; set; }
}

class CCC
{
    public string MyString { get; set; }
}

If I want to get the last string of my objects via this JScript-Code I get the error

var x = MyObject.Bbb.Ccc.MyString;

How can I do this?

1

There are 1 answers

0
masterchris_99 On BEST ANSWER

I have to add to every class the ComVisible(true) attribute and not only to the first AAA Class

[ComVisible(true)]
public class AAA
{
    public BBB Bbb { get; set; }
}

[ComVisible(true)]
public class BBB
{
    public CCC Ccc { get; set; }
}

[ComVisible(true)]
public class CCC
{
    public string MyString { get; set; }
}