Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting COM object returned by IHTMLDocument2.Script.InvokeMember() to something useful

I'm working with some code in C#.NET for an Internet Explorer extension that calls Javascript in the browser and gets the return value from the Javascript call. When the Javascript returns a primitive type or an array of primitive types, I get something that I can deal with, but when the Javascript returns an object, I get an opaque COM object.

How can I get at the contents of the COM object, or is there a better way to call into IE from C#.NET?

like image 515
Greg Avatar asked May 13 '26 10:05

Greg


1 Answers

Take a look at the remarks at the bottom of the InvokeMember documentation. If the return value is a javascript object, you are receiving a .NET Object wrapper around the javascript object. You will have to use reflection to inspect/invoke the members of the underlying javascript object. This makes perfect sense, since javascript is a dynamic language and C# is not.

like image 77
jlew Avatar answered May 14 '26 23:05

jlew