0xc0020001 Exception in AUT when shutting down

Ask general questions here.
User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

0xc0020001 Exception in AUT when shutting down

Post by Ciege » Mon Nov 09, 2009 7:44 pm

This is a strange one, and not necessarily a Ranorex issue, but just in case wanted to get your perspective on it.

When running some of my tests one step is to shut down the AUT and restart it. Using File -> Exit in my AUT from Ranorex causes the 0xc0020001 Exception in the AUT. However, when I follow all of the steps EXACTLY manually I cannot reproduce the exception. I can reproduce it close to 99% of the time from automation.

I have my dev team taking a cursory look. But since there is 0% reproducibility manually they have it marked very low priority for them (and as with any dev team, they have lots of other important things to be working on).

So, if you guys have any suggestions I am all ears!

Thanks...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: 0xc0020001 Exception in AUT when shutting down

Post by Support Team » Tue Nov 10, 2009 6:27 pm

Ciege wrote:So, if you guys have any suggestions I am all ears!
Never saw that error before, sorry!

What kind of application is it (.NET WinForms, WPF, MFC, ...)?
What does the File->Exit do? If .NET application, is Environment.Exit() called or is the application shut down by unmanaged code?

Regards,
Alex
Ranorex Support Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: 0xc0020001 Exception in AUT when shutting down

Post by Ciege » Thu Nov 12, 2009 12:08 am

.Net Winforms app. No C++ managed code (that I am aware of).

If I replace the File -> Exit with a Ranorex Form.Close() I get this Ranorex exception:

Ranorex.ActionFailedException: Action 'close' failed on element '{Form:Hard Dollar}'. ---> System.InvalidOperationException: The control does no longer exist. at Ranorex.Plugin.WinFormsFlavorElement.InvokeMethod(BindingFlags flags, String name, Object[] args) at Ranorex.Plugin.WinFormsFlavorElement.InvokeAction(Element element, String name, Object[] args) at Ranorex.Core.Element.InvokeAction(String name, Object[] args) --- End of inner exception stack trace --- at Ranorex.Core.Element.InvokeAction(String name, Object[] args) at Ranorex.Form.Close() at RanorexFramework.RFW.HardDollarExitClient(Form RanorexFormName, Boolean boolSaveJobs) in C:\Documents and Settings\Admin\My Documents\Visual Studio 2008\Projects\RanorexFramework\RanorexFramework\Class1.cs:line 357

I am trying to go through section by section removing tests until the failure no longer occurs and then add back other sections to find a path where everything is happy (this is a lengthy process!). I have found out that just starting and exiting my AUT from Ranorex produces no exception (in my AUT or Ranorex) so I need to figure out what the trigger is... Ugh...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: 0xc0020001 Exception in AUT when shutting down

Post by Support Team » Thu Nov 12, 2009 4:47 pm

That exception ("The control does no longer exist.") should only be thrown if the control isn't there any more. Could you check the value of the Form.Valid property before calling the Close() method?

I found an article from Microsoft concerning the 0xC0020001 exception stating that it could be a managed/unmanaged code interaction problem.
In order to interact with WinForms controls, Ranorex injects code into the automated application. The injected code is mainly managed, but some unmanaged parts are needed. So it could be that the exception is caused by the unmanaged part of the injected code. We never had any similar problems before, though...

Regards,
Alex
Ranorex Support Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: 0xc0020001 Exception in AUT when shutting down

Post by Ciege » Thu Nov 12, 2009 5:12 pm

Form.Valid = TRUE right before I call Form.Close().


Some more information...
I've limited it down to when I can trigger the exception to occur to this instance.
1) when I use a print preview dialog that is spawned by the AUT.

When I remove the parts of Automation the trigger the print preview dialog I can successfully open/close out AUT along with many tests several times. I ran this overnight through 100 iterations without failure.

Again, this is ONLY happening when using Ranorex to test and close the AUT. I (and others) have been 0% at getting this to happen manually.
You do not have the required permissions to view the files attached to this post.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: 0xc0020001 Exception in AUT when shutting down

Post by Ciege » Wed Nov 18, 2009 4:36 pm

Have you guys made any headway into this? I have had to workaround the issue by not closing my AUT at any time via Ranorex automation, which is obviously kind of bad when I need to test shutting down and restarting my AUT in multiple scenarios.

Thanks...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: 0xc0020001 Exception in AUT when shutting down

Post by Support Team » Thu Nov 19, 2009 11:35 am

Sorry, I still don't have a clue where this exception is coming from. It seems to be a problem specific to your application, because I tried reproducing it with some print preview dialogs (default WinForms, DevExpress) but didn't succeed.

What kind of print preview control do you use?
Does the exception happen only when you close the window using the File->Exit menu item or using the windows 'x' button as well?

Could you provide us with a sample application that we can reproduce the problem with? I think that this is the only option how we could possibly reproduce and fix that issue.

Regards,
Alex
Ranorex Support Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: 0xc0020001 Exception in AUT when shutting down

Post by Ciege » Thu Nov 19, 2009 5:48 pm

I'll see if I can get a sample app to you. we are at the end of a release cycle so time is of the essence for our dev team.

The AUT exception occurs when I use File -> Close OR clicking the close button "X" in the AUT.

Do you have any suggestions for the ActionFailed exception where Ranorex can't even close the AUT using the .Close method?

Thanks...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: 0xc0020001 Exception in AUT when shutting down

Post by Support Team » Fri Nov 20, 2009 3:08 pm

Ciege wrote:Do you have any suggestions for the ActionFailed exception where Ranorex can't even close the AUT using the .Close method?
That's another weird thing. That exception should only be thrown if the communication did not succeed, i.e. if the control did not respond to the window message. However, if the form is still valid, the native window for that control should still be there, it just does not react to the message Ranorex sends to it.

You could try using the Control.InvokeRemotely method and see if you can still invoke a delegate on the control or if you get the same exception.

Regards,
Alex
Ranorex Support Team