well, I am building an update application for my project,and the way i'm checking if there are new updates is by a webBrowser. Here is the function that checks for updates (it's called by the OnDocumentCompleted event):
(sorry the messages are in Polish)Code:void Check() { string content = webBrowser1.DocumentText; string[] checking = content.Split('|'); string data = checking[1]; if (data != "_MTL_VERSIONS_EQUAL_") { ProcessData(data); if(MessageBox.Show("Znaleziono w internecie poprawkę, z wersji aktualnej - "+version+", na "+upVersion+". Czy chcesz ją pobrać?", "Łatki - Multitool Update", MessageBoxButtons.YesNo)==DialogResult.Yes) { MessageBox.Show("Za chwilę rozpocznie się pobieranie i instalacja łatki.", "Łatki - Multitool Update", MessageBoxButtons.OK, MessageBoxIcon.Information); RegistryKey rejestr=Registry.CurrentUser.OpenSubKey("software\\multitool\\UpDate",true); fPath = Convert.ToString(rejestr.GetValue("DownPath"));//tymczasowa zmiana button2.Text="Anuluj"; thr=new Thread(new ThreadStart(Download)); thr.Start(); } else { Application.Exit(); } } else { MessageBox.Show("Nie znaleziono żadnych poprawek.","Łatki - Multitool Update", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } } void WebBrowser1DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e) { thr=new Thread(new ThreadStart(Check)); thr.Start(); }
and it gives out an error:
An unhandled exception of type 'System.InvalidCastException' occurred in System.Windows.Forms.dll
Additional information: Specified cast is not valid.
The error is in the line:
string content = webBrowser1.DocumentText;
The documentText value is string so why is it giving out the error?
Please answer quickly.
Last edited by McMillan0520; 08-05-2007 at 10:48 AM. Reason: -
Right, I fixed it. The problem was in a completely different part of the code. I used the same thread reference twice.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks