Skip to content

WinEventHook.Dispose exception when reloading an add-in? #67

@alainbryden

Description

@alainbryden

Some new behaviour with the latest Intellisense version:

If I (e.g. accidentally) load my add-in while it's already loaded (which is admittedly undefined behaviour), Excel now crashes due to the following exception:

System.InvalidOperationException
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
   at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)

If I attach a debugger, the call stack when it's thrown is:

 	System.Windows.Forms.Control.MarshaledInvoke(caller, method, args, synchronous)	Unknown
 	System.Windows.Forms.Control.Invoke(method, args)	Unknown
 	System.Windows.Forms.WindowsFormsSynchronizationContext.Send(d, state)	Unknown
>	ExcelDna.IntelliSense.WinEventHook.Dispose()	Unknown
 	ExcelDna.IntelliSense.UIMonitor.Dispose.AnonymousMethod__19_0(<p0>)	Unknown
 	ExcelDna.IntelliSense.SingleThreadSynchronizationContext.RunOnCurrentThread()	Unknown
 	System.Threading.ExecutionContext.RunInternal(executionContext, callback, state, preserveSyncCtx) Line 954	C#
 	System.Threading.ExecutionContext.Run(executionContext, callback, state, preserveSyncCtx) Line 902	C#
 	System.Threading.ExecutionContext.Run(executionContext, callback, state) Line 891	C#
 	System.Threading.ThreadHelper.ThreadStart() Line 111	C#
 	[Native to Managed Transition]	

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions