Question

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?

Was it helpful?

Solution

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; }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top