I’m hosting my WinForms control in Internet Explorer. Additionally I’ve implemented IExpando interface to be able to emulate unexisted fields and methods in my C# code when javascript code try to access them. For example
var myobj = new ActiveXObject('server.object');
myobj.Foo = "FooText";
myobj.Bar("BarText");
Note that my C# class doesn’t contain Foo field and Bar method. IExpando.AddField will be called with parameter name=”Foo”, but IExpando.AddMethod will not be executed.
In case of myobj.Bar(“BarText”); only IReflect.GetMethods, IReflect.GetProperties and IReflect.GetFields methods will be executed.
Does anyone knows why IExpando.AddMethod was not called?
Thanks,
Paul.
I think from js, AddMethod will never be called. Since “methods” are actually just properties with delegates as their value. Calling a function like that is actually getting a property then invoking it.
In that case you’ll get a member missing exception, same as it would with a js object. You can try setting it first though:
That would work! Otherwise I think you need to know about it ahead of time and return it in GetProperties.