Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

(WebBrowser.Document == null) throws InvalidCastException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zytan - 27 Mar 2007 18:21 GMT
if (webBrowserControl.Document == null) is throwing an
InvalidCastException.

PLEASE NOTE: ***The function being called is being called from a
thread OTHER THAN than the one that created the WebBrowser
control.***  So, I think making a delegate to invoke the function from
the proper thread will solve the problem.  But, I just want to know:

Why is the above exception happening?  Where is the cast?

The StackTrace for the exception (there is no InnerException):

"   at
System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation()\r
\n   at System.Windows.Forms.WebBrowser.get_Document()\r\n   at MY OWN
FUNCTION... etc."

So, I guess the answer is in the above function.

Zytan
Zytan - 27 Mar 2007 18:54 GMT
> PLEASE NOTE: ***The function being called is being called from a
> thread OTHER THAN than the one that created the WebBrowser
> control.***  So, I think making a delegate to invoke the function from
> the proper thread will solve the problem.

Yes, it does fix the problem, as I expected.

Zytan
RuMiL - 21 Jun 2007 18:06 GMT
Could you tell me how did you solve the problem with the delegate please?
Would be great if you see this message as soon as possible  :S

Thanks in advance.

>> PLEASE NOTE: ***The function being called is being called from a
>> thread OTHER THAN than the one that created the WebBrowser
[quoted text clipped - 4 lines]
>
>Zytan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.