Invoke or BeginInvoke cannot be called...Solved

Hi

I'm getting the following exception from AutomaticUpdater control when my application starts (with the latest Version):

Stacktrace bei System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bei System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) bei System.Delegate.DynamicInvokeImpl(Object[] args) bei System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) bei System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) bei System.Threading.ExecutionContext.runTryCode(Object userData) bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) bei System.Windows.Forms.Control.InvokeMarshaledCallbacks() bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei ch.hbs.moto.cl.Program.Main() in C:\Projects\HBS_KMU\Kmu\Client\src\Program.cs:Zeile 69.Inner Exception

Caused by: Message: Invoke oder BeginInvoke kann f ein Steuerelement erst aufgerufen werden, wenn das Fensterhandle erstellt wurde. bei System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) bei System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) bei wyDay.Controls.AutomaticUpdater.auBackend_CheckingFailed(Object sender, FailArgs e) bei wyDay.Controls.AutomaticUpdaterBackend.UpdateStepFailed(UpdateStepOn us, FailArgs args) bei wyDay.Controls.AutomaticUpdaterBackend.updateHelper_PipeServerDisconnected(Object sender, UpdateHelperData e) bei wyDay.Controls.UpdateHelper.bw_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) bei System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e) bei System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)

Looks like AutomaticUpdater calls Invoke on the owner form before the form's handle is created. You should wait until ownerForm.IsHandleCreated returns true before doing anything with the ownerForm.

Can you fix this?

What version of the AutomaticUpdater? Are you calling any functions in your form's constructor?

Hi

Version: 2.6.18.0

Yes I call some functions in the constructor of the form. Initialize some resources, show a splash sreen (async), set up the style from the gui (3th part library -> infragistic) and log some informations...

sorry my mistake 😮 I've integrated a standalone app in my main app. The main app and the other form to integrate had an automatic updater...I forgot to remove the automatic updater after the integration on the form (need only the one from the main app). Now I removed the updater - and everything runs fine 😛 Thanks!