Failed to register DragDrop Error
Posted: Mon Aug 28, 2017 5:55 pm
Hello,
I developpe an Ranorex automation project with C# of .NET desktop Application that uses Magics
Sometimes when I run Test case or test suite the dragDrops Exception triggers and block the test.
the exception description is :"System.InvalidOperationException: Failed to register DragDrop. ---> System.Threading.ThreadStateException: The current thread must be in STA mode (Single Thread
Apartment) before OLE calls can be made. Make sure your Main function is marked as STAThreadAttribute.".
I verify the Main function in "Program.cs and I found it right . the main :
Regards
I developpe an Ranorex automation project with C# of .NET desktop Application that uses Magics
Sometimes when I run Test case or test suite the dragDrops Exception triggers and block the test.
the exception description is :"System.InvalidOperationException: Failed to register DragDrop. ---> System.Threading.ThreadStateException: The current thread must be in STA mode (Single Thread
Apartment) before OLE calls can be made. Make sure your Main function is marked as STAThreadAttribute.".
I verify the Main function in "Program.cs and I found it right . the main :
class Program { [STAThread] public static int Main(string[] args) { // Uncomment the following 2 lines if you want to automate Windows apps // by starting the test executable directly // if (Util.IsRestartRequiredForWinAppAccess) // return Util.RestartWithUiAccess(); Keyboard.AbortKey = System.Windows.Forms.Keys.Pause; int error = 0; try { error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine); } catch (Exception e) { Report.Error("Unexpected exception occurred: " + e.ToString()); error = -1; } return error; } }Thank you for Helping me
Regards