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

Frage
-
Hallo Forum
Hallo Forum
Einige User melden, dass beim Starten einer Windows-Applikation eine Fehlermeldung erscheint:
Unhandled excepion has occurred... (Details siehe ganz unten).Der Fehler tritt nur beim ersten Mal starten nach einem PC-Neustart auf. Die Appl. muss dann beendet werden (teilweise nur mit dem Taskmanager möglich). Jedes weitere Mal starten funktioniert danach.
Es ist auch keine Regelmässigkeit feststellbar. Bei einige User häufiger, andere selten. Ich kann es in der Entwicklungsumgebung jedoch nicht nachvollziehen.Was ich inzwischen (mit Hilfe einer Log-Datei) herausgefunden habe: der Startvorgang hängt beim Laden vom MDI-Form
log_zeile_1: MyApplication_Startup_start
log_zeile_2: SplashScreenEFS_Load_start
log_zeile_3: SplashScreenEFS_Load_ende
log_zeile_4: MyApplication_Startup_ende
log_zeile_5: frmMdi_Load_start
log_zeile_6: frmMdi_Load_ende-> (hier dazwischen kommt die unhandled exception) <-
log_zeile_7: frmMdi_Shown_start
log_zeile_8: frmMdi_Shown_endeIm Fehler-Fall wird nur bis Zeile 6 ins LogFile geschrieben. Im Normalfall läuft es bis zur Zeile 8 durch.
Die Applikation (in VB.NET) wurde ins VS-2010 migriert und für Framework-4 kompiliert. Die Clients laufen mit win-7 Enterprise SP1 (x64). Zuvor lief es problemlos mit VS-2005 Framework-2 auf win-XP.
Vielen Dank für Tips und Hinweise
Markus Baur
************** Exception Text **************
System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
at System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle)
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.Invoke(Delegate method)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.HideSplashScreen()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.MainFormLoadingDone(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Alle Antworten
-
Hallo Markus Baur,
Schau Dir mal folgenden Diskussionsfaden an. Vielleicht kann er Dir weiterhelfen.
http://www.codeproject.com/Questions/326541/Invoke-or-BeginInvoke-Exception
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
Lies hier auch noch: Control.InvokeRequired Property -à „In the case where the control's handle has not yet been created, you should not simply call properties, methods, or events on the control. This might cause the control's handle to be created on the background thread, isolating the control on a thread without a message pump and making the application unstable.“
Grüße,
Robert
Robert Breitenhofer, MICROSOFT
Bitte haben Sie Verständnis dafür, dass im Rahmen dieses Forums, welches auf dem Community-Prinzip „Entwickler helfen Entwickler“ beruht, kein technischer Support geleistet werden kann oder sonst welche garantierten Maßnahmen seitens Microsoft zugesichert werden können.
-
Hallo Markus Baur,
Könntest Du Dein Problem lösen? Wenn ja, es wäre schön, wenn Du posten würdest wie es funktioniert hat, denn dann profitieren unter Umständen andere mit dem gleichen Problem davon.
Grüße,
RobertRobert Breitenhofer, MICROSOFT
Bitte haben Sie Verständnis dafür, dass im Rahmen dieses Forums, welches auf dem Community-Prinzip „Entwickler helfen Entwickler“ beruht, kein technischer Support geleistet werden kann oder sonst welche garantierten Maßnahmen seitens Microsoft zugesichert werden können.