InvalidOperationException when Activating Document Window

Docking/MDI for Windows Forms Forum

Posted 16 years ago by Miriam Kuruvilla
Version: 2.0.99
Avatar
I inherited from the DocumentWindow class to create my own class 'Page'.
When I call Activate on the Page object from a COM object's message handler, I get the following error.
A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.
   at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
   --- End of inner exception stack trace ---
   at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
   at System.Windows.Forms.Control.set_AllowDrop(Boolean value)
   at ActiproSoftware.UIStudio.Dock.TabbedMdiContainer..ctor(DockManager dockManager)
   at ActiproSoftware.UIStudio.Dock.DockManager.b(TabbedMdiWindow A_0)
   at ActiproSoftware.UIStudio.Dock.DocumentWindow.Activate(Boolean focus)
   at ActiproSoftware.UIStudio.Dock.TabbedMdiWindow.Activate()
   at ClickTrader.Layout.AddPage(Page p) in C:\Documents and Settings\mkuruvil\My Documents\Visual Studio 2005\Projects\ClickTrader\ClickTrader\Layout.cs:line 90
   at ClickTrader.Layout..ctor(DockManager dM, String layoutFile) in C:\Documents and Settings\mkuruvil\My Documents\Visual Studio 2005\Projects\ClickTrader\ClickTrader\Layout.cs:line 55
   at ClickTrader.ClickTrader.objConfig_OnAttribute(String strAttributeName, String strAttributeValue) in C:\Documents and Settings\mkuruvil\My Documents\Visual Studio 2005\Projects\ClickTrader\ClickTrader\ClickTrader.cs:line 148
I need to get a value from the COM and load a document window based on that value.
I already have [STAThread] specified in Main.
I works without any issues when I call activate outside of the COM message handler.

How do I fix this issue? Please help!
Thanks!

Comments (1)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you google "DragDrop registration did not succeed" you will find literally hundreds of messages on that error. It seems to be a common issue with Windows Forms in general but most solutions say to add the [STAThread] attribute to fix it.

If you are introducing COM message loops into the equation then unfortunately that is beyond the scope of what we do. So you'd have to search on the net to see if people have had similar exceptions when calling other controls from a COM message handler.

Also as a side note, we don't do anything special with AllowDrop other than set it to true and our code doesn't do any explicit interaction with COM.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.