In our coded tests, if we set Keyboard.AbortKey, a System.AppDomainUnloadedException is reported when the test completes.
We set the key using:
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
And this is what is recorded:
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
Is there any way of preventing this exception, whilst still setting AbortKey ?
Thanks,
John H.
Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Interestingly, use of the following also results in the same exception:
IList<Form> forms = Host.Local.Find<Form>(String.Format("/form[@processname='{0}']", processName));
Whilst the exception is not causing any major problems, it does generate noise that distracts from failures in the code under test.
Any ideas?
Thanks,
John H.
IList<Form> forms = Host.Local.Find<Form>(String.Format("/form[@processname='{0}']", processName));
Whilst the exception is not causing any major problems, it does generate noise that distracts from failures in the code under test.
Any ideas?
Thanks,
John H.
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
I should add that we run our coded Ranorex tests as MSTest tests, using TestInitialize to ensure a known state before each test and TestCleanup to tidy up afterwards.
Regards,
John H
Regards,
John H
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi John,
Unfortunately I was not able to reproduce this exception on my machine.
May I ask you to provide us a sample solution in which this problem occurs?
If you don’t want to post the solution in this public forum you can send it to [email protected]
Thank you in advance.
Regards,
Markus (S)
Unfortunately I was not able to reproduce this exception on my machine.
May I ask you to provide us a sample solution in which this problem occurs?
If you don’t want to post the solution in this public forum you can send it to [email protected]
Thank you in advance.
Regards,
Markus (S)
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi Markus,
My understanding of that exception suggests that within the Ranorex libraries, one or more threads are being started, but they are not ending. As a result, as we run our tests from MSTest, MSTest detects that there are threads still running at the end of a test, and generates that exception.
So, the question is - is there any way that in TestCleanup (where cleanup code is placed for MSTest tests), we can tell the Ranorex libraries that we are finished with them and that they should end any threads that they started? What we need is something skin to Ranorex.Shutdown or Ranorex.End.
Thanks,
John H.
My understanding of that exception suggests that within the Ranorex libraries, one or more threads are being started, but they are not ending. As a result, as we run our tests from MSTest, MSTest detects that there are threads still running at the end of a test, and generates that exception.
So, the question is - is there any way that in TestCleanup (where cleanup code is placed for MSTest tests), we can tell the Ranorex libraries that we are finished with them and that they should end any threads that they started? What we need is something skin to Ranorex.Shutdown or Ranorex.End.
Thanks,
John H.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi Josh,
Ranorex does not start any threads which are not closed at the end. May I ask you, if you have started an additional thread? For example: a PopupWatcher?
May I also ask you to provide a small sample of your test where this exception occurs.
Additionally: Please let me know which version of Ranorex is currently installed on your system.
This will help us to analyze the issue in more detail.
regards,
Markus(S)
Ranorex does not start any threads which are not closed at the end. May I ask you, if you have started an additional thread? For example: a PopupWatcher?
May I also ask you to provide a small sample of your test where this exception occurs.
Additionally: Please let me know which version of Ranorex is currently installed on your system.
This will help us to analyze the issue in more detail.
regards,
Markus(S)
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi Markus,
Whilst we do normally have a PopupWatcher in use, we still see this exception being reported if the PopupWatcher code is completely removed.
I'll put together a small piece of code to demo the problem.
Thanks,
John H
Whilst we do normally have a PopupWatcher in use, we still see this exception being reported if the PopupWatcher code is completely removed.
I'll put together a small piece of code to demo the problem.
Thanks,
John H
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi Markus,
Here you go. The following results in the error appearing, using 5.1.1.18898:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace DemoOfExceptionForRanorex
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Ranorex.Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
}
}
}
If I remove the line setting AbortKey, then the exception no longer happens.
Regards,
John H.
Here you go. The following results in the error appearing, using 5.1.1.18898:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace DemoOfExceptionForRanorex
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Ranorex.Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
}
}
}
If I remove the line setting AbortKey, then the exception no longer happens.
Regards,
John H.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi John,
Sorry for the slow response. I tried several times to reproduce this issue.
I regret to inform you that I was not able to reproduce the problem on our side.
Please find below two screenshots, where you can see that the code works as expected. Unfortunately, it seems that this problem is not related to Ranorex. May I ask you to have a look at this entry on the MSDN forum
Regards,
Markus (S)
Sorry for the slow response. I tried several times to reproduce this issue.
I regret to inform you that I was not able to reproduce the problem on our side.
Please find below two screenshots, where you can see that the code works as expected. Unfortunately, it seems that this problem is not related to Ranorex. May I ask you to have a look at this entry on the MSDN forum
Regards,
Markus (S)
You do not have the required permissions to view the files attached to this post.
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi Markus,
Thanks for your response.
Using the Threads window when debugging in Visual Studio, I see that the following three threads are started when I set Keyboard.AbortKey:
Ranorex.Core.dll!Ranorex.Core.InputDispatcher.DispatcherThread
Ranorex.Core.dll!Ranorex.Core.InputDispatcher.RegeneratorThread
Ranorex.Core.dll!WinApi.dll!Ranorex.Core.WinApi.Hooks.MessageLoop
Is there any way that tests can cleanly exit these threads, perhaps a Shutdown or Cleanup type method in the Ranorex API?
I assume that the test runner is reporting the exception mentioned before as a result of these threads being started during a test, but at least one of them not being closed at the end of the test.
Thanks again,
John H.
Thanks for your response.
Using the Threads window when debugging in Visual Studio, I see that the following three threads are started when I set Keyboard.AbortKey:
Ranorex.Core.dll!Ranorex.Core.InputDispatcher.DispatcherThread
Ranorex.Core.dll!Ranorex.Core.InputDispatcher.RegeneratorThread
Ranorex.Core.dll!WinApi.dll!Ranorex.Core.WinApi.Hooks.MessageLoop
Is there any way that tests can cleanly exit these threads, perhaps a Shutdown or Cleanup type method in the Ranorex API?
I assume that the test runner is reporting the exception mentioned before as a result of these threads being started during a test, but at least one of them not being closed at the end of the test.
Thanks again,
John H.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Keyboard.AbortKey and System.AppDomainUnloadedExcepti
Hi John,
Thank you for the response.
Unfortunately we were still not able to reproduce this System.AppDomainUnloadedException.
May I ask you to contact us by email to handle this problem personally with us?
Thank you for your understanding and your patience.
Regards,
Markus (S)
Thank you for the response.
Unfortunately we were still not able to reproduce this System.AppDomainUnloadedException.
May I ask you to contact us by email to handle this problem personally with us?
Thank you for your understanding and your patience.
Regards,
Markus (S)