System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException:
What does this except
I found this error, and I see that the one that making it shown is when using another thread calling MessageBox.Show(this, ...)
, where this is not done initialized.
We need to remove the owner of the message box to remove the error.
Add the STAThreadAttribute attribute on the Main method. This attribute is required if your program access OLE related functions, like Clipboard class does.
[STAThread]
static void Main(string[] args)
{
}
I solved this error by using below code...I were using Background Worker and trying to access UI while background worker..that is why getting error - DragDrop registration did not succeed. We cannot access UI from the code running in background worker or in thread.
BeginInvoke((MethodInvoker)delegate
{
//write your code here...
});
Thanks Happy Coding... :