When using WebBrowser
control I would like to pass an object from javascript code to C#.
Solution is known - using ObjectForScripting
property of WebBrowser
and invoking methods from javascript code using window.external
.
I know how to do that, but I would like to create object with given type in javascript and pass it to C# without using object
or dynamic
. Example:
I would like to call from JS this method in C#:
public void Test(Foo foo)
{
//do something
}
Where Foo
is:
[ComVisible(true)]
public class Foo
{
public string Bar;
}
I know how to call those methods:
public void Test2(object foo)
{
//do something
}
public void Test3(dynamic foo)
{
//do something
}
but I would like to use the first one - Test(Foo foo)
What should I do to make it possible to pass object of class Foo
from JS to C# or how to cast JS object on the fly to C# Foo
object?