This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
5 Replies Last post: Jul 20, 2012 3:03 PM by Ekaterina Solovova  
Pim Witlox Newbie 3 posts since
Jan 2, 2012
Currently Being Moderated

Jan 2, 2012 2:58 PM

Coverage : Forms Unit Test >  DragDrop registration did not succeed

When running a coverage (commandline) on one of our assemblies the following exception keeps occurring:

 

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

 

************** Exception Text **************

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.OnHandleCreated(EventArgs e)

   at System.Windows.Forms.Control.WmCreate(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

   at System.Windows.Forms.ContainerControl.WndProc(Message& m)

   at System.Windows.Forms.UserControl.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)

 

 

This might be due to the thread appartment state of the calling application.

Is it possible to set dotCover to use STA?

Ruslan Isakiev JetBrains 181 posts since
Mar 22, 2010
Currently Being Moderated
Jan 11, 2012 2:51 PM in response to: Pim Witlox
Re: Coverage : Forms Unit Test >  DragDrop registration did not succeed

Hello Pim,

Thank you for the feedback.
I've filed an issue for this our tracker:
http://youtrack.jetbrains.net/issue/DCVR-3321
You are welcome to track its status.

Ruslan Isakiev JetBrains 181 posts since
Mar 22, 2010
Currently Being Moderated
Jan 11, 2012 3:04 PM in response to: Pim Witlox
Re: Coverage : Forms Unit Test >  DragDrop registration did not succeed

Sure, I've closed DCVR-3321 as duplicate.

Ekaterina Solovova JetBrains 27 posts since
Jun 26, 2012
Currently Being Moderated
Jul 20, 2012 3:03 PM in response to: Pim Witlox
Re: Coverage : Forms Unit Test >  DragDrop registration did not succeed

Hello Pim,

I am very sorry for such a long delay!

 

I have investigated your issue and I guess that dotCover can't be the cause of your problem. It runs NUnit's console in a separate process and doesn't have any influence on its threading model. Please make sure that you have configured your tests and NUnit's console properly. To run tests in STA threads with NUnit 2.5 or newer you can use either configuration file or RequiresSTAAttribute (please see NUnit's documentation on it at http://nunit.org/index.php?p=requiresSTA&r=2.5). If you use configuration file please make sure that it has correct name (assembly_with_tests_name.dll.config) and is placed in the same directory as the assembly with tests at run time. Both configuration file and attribute work fine for me with dotCover 1.2 and 2.0 and NUnit 2.5.10.

 

Regards.

More Like This

  • Retrieving data ...