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 / Windows Forms / WinForm Controls / May 2008

Tip: Looking for answers? Try searching our database.

Invoke or BeginInvoke cannot be called on a control until the window     handle has been created.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rof - 13 May 2008 11:33 GMT
Help, please!

I have seen a couple of threads about this message, but they seem to
have a much more complicated situation than mine, and they aren't much
help.

I have a form from which a call is made to a serial port, using
"Friend WithEvents sPort As SerialPort". This goes to a piece of kit
which, after a couple of seconds, returns a message. Now, because it's
listening for it in a global module, and also the use of SerialPort
takes place on a new thread, I use an EventHandler to raise an event
which the original form can handle, to show the returned data, and an
"Invoke" to handle cross-thread calls.  I also have
"Control.CheckForIllegalCrossThreadCalls = False" in the form. But
when it hits a "Me.invoke" (or <any control on the form>.invoke), it
fails with this message:

"Invoke or BeginInvoke cannot be called on a control until the window
handle has been created."

Now I'm not doing anything fancy to create the form, it's just in the
designer. And the form is not closed or made invisible between
actioning the "send" and receiving the event from the "RaiseEvent" in
the routine that's listening for the returned data. Looking at the
other threads, I tried to create a handle (dim xx as Long = Me.Handle)
- but it said "Cannot access a disposed object." So, WHY is my form
disposed??? Given that it is, I can see why I get the first error, but
what on earth is disposing it????

Help, please!!

Peter Royle
Dick Grier - 13 May 2008 17:07 GMT
I have never seen this.... However, I enable the serial port in the form
Load event (there certainly is no need to do this earlier).  Perhaps you can
do the same?

Dick

Signature

Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.


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.