I am running this piece of code:
Code: C#
public static string GetUserAgent()
{
var userAgent = "";
try
{
var thRunner = new ThreadRunner();
var webView = thRunner.CreateWebView();
thRunner.Send(() =>
{
webView.LoadUrlAndWait("about:blank");
userAgent = webView.EvalScript("navigator.userAgent").ToString();
});
thRunner.Stop();
}
catch (Exception ex)
{
// ignore
}
return userAgent;
}
The idea is to extract the userAgent. This works on 99% of computers. But for example, on some Windows 7 (Spanish) version it does not always work. We have not found reason for this. The exception we get is:
Code: C#
EO.Internal.jq+e: Child process exited unexpectedly.
at EO.Base.ThreadRunnerBase.f.a(Int32 A_0, Boolean& A_1)
at EO.Base.ThreadRunnerBase.Send(ActionWithResult action, Int32 timeoutInMS, Boolean& done)
at EO.WebBrowser.ThreadRunner.a(Int32 A_0, Int32 A_1, Boolean A_2, BrowserOptions A_3)
at WebAutomation.WebAuto.AENHFKOMDOELCJJKFJCDPBLMPIFDPLMEIOHL(Object )
at WebAutomation.WebAuto.GetUserAgent() in c:\sourcefiles\VisualCron - Addons\WebAuto\WebAutomation\WebAuto.cs:line 235
After adding the Exception handling we got this error (similar, from other place):
It occurs in this code:
Code: Visual Basic.NET
AddHandler pb.HandleCreated, Sub(sender, args)
wv.Create(pb.Handle)
pb.Tag = wv
End Sub
I am suspecting that the computers in question are slower than other which may result in a timeout but how can this be handled?