Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Unit test using PrincipalContext causes AppDomainUnloadedException in test outpu

$
0
0

Hi, while running our tests on our TFS build server we always have a warning in the "Other Errors and Warnings":

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.

I narrowed it down to some tests of a class using PrincipalContext. Then I was able to reproduce the problem with this minimal test:

<TestMethod()>
Public Sub PrincipalContext_DomainOnly_AppDomainUnloadedException()
     Using ctx = New PrincipalContext(ContextType.Domain)
     End Using
End Sub

When run through the built-in VS test runner, I get in the Output / Tests window:

------ Run test started ------
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.

Any idea how to solve this? Thanks!


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>