0

I have a project that reads content from web and saves it to the database.

I use Timer control to wait for ajax changes and it has been working for a long time without any problem.

But unexpectedly it is not working any more. I get the following error :

Exception thrown: 'System.Runtime.InteropServices.COMException' in SnapshotInfo.exe

Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.

Part of the code on this problem :

    WebBrowser _browser = new WebBrowser();
    private void Form1_Load(object sender, EventArgs e)
    {
        _browser.Dock = DockStyle.Fill;
        _browser.DocumentCompleted += _browser_DocumentCompleted;
        Controls.Add(_browser);
    }

    private void _browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {

        if (!timer1.Enabled)
        {
            // do any thing
        }

    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        _browser.Dispose();
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (_browser.Document==null || _browser.Document.Body==null) return;
        var body = _browser.Document.Body.InnerHtml; // ----> error here
        if (body.Contains("word"))
        {
            // code when word is exist
            timer1.Enabled = false;
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        _browser.Navigate(textBox1.Text);
        timer1.Enabled = true;
    }

I do not know where is the problem?

Thanks for any help

Nikhil Vartak
  • 5,002
  • 3
  • 26
  • 32

2 Answers2

0

Make sure you are using latest version of web browser control , check below link

Use latest version of Internet Explorer in the webbrowser control

or you can replace web browser control with another web browser engine like http://www.awesomium.com/ it's free and easier to use

Community
  • 1
  • 1
Sam Jolan
  • 67
  • 5
  • Webbrowser Control version is 11.0.10240.16485 Use Awesomium engine is second plan,Because rewrite the code takes time. thanks – user4502388 Oct 05 '15 at 06:39
0

The problem solved by deleting the security update KB3087040!

Box Box Box Box
  • 5,094
  • 10
  • 49
  • 67