I am searching for .NET library/component which will allow me do following:
The only solution I have found so far is using WebBrowser object, but it requires a good chunk of boilerplate code to make everything work and it fails to work with an array of objects.
In the following code sample, I receive a RuntimeBinderException on dynamic val = o.a;
class Program
{
[STAThread]
static void Main(string[] args)
{
var t = new System.Threading.Thread(BrowserThread);
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
Console.ReadLine();
}
private static void BrowserThread()
{
var wb = new WebBrowser();
wb.Navigate("http://google.com");
wb.DocumentCompleted += (sender, args) =>
{
var head = wb.Document.GetElementsByTagName("head")[0];
var script = wb.Document.CreateElement("script");
dynamic el = script.DomElement;
el.text = "function test(){return [{a:2},{a:2},{a:2}]}";
head.AppendChild(script);
dynamic result = wb.Document.InvokeScript("test");
dynamic o = result.pop();
dynamic val = o.a;
};
Application.Run();
}
}
Can anyone provide an alternative solution or help to fix this one?
you could try dynamic a = o[0].a; or dynamic a = result[0].a; and see if that helps...
Another point: you should check the type of result by stepping though your code... this might help finding a working answer...
Regarding alternatives there are some options:
WebKit.Net (free)
Awesomium
It is based on Chrome/WebKit and works like a charm.
There is a free license available but also a commercial one and if need be you can buy the source code :-)
WatiN (also free)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With