Mathieu Fenniak has proposed merging lp:~mfenniak/nunitv2/AppDomainUnloadFailure into lp:nunitv2.
Requested reviews: NUnit Core Developers (nunit-core) Fixes an occasional unhandled exception from NUnit, when attempting to unload an AppDomain that has already been unloaded. Unhandled Exception: System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. at System.AppDomain.get_FriendlyName() at NUnit.Util.DomainManager.DomainUnloader.Unload() at NUnit.Util.TestDomain.Unload() at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options) at NUnit.ConsoleRunner.Runner.Main(String[] args) The fix is to abort without error when the target AppDomain is already unloaded. -- https://code.launchpad.net/~mfenniak/nunitv2/AppDomainUnloadFailure/+merge/32099 Your team NUnit Core Developers is requested to review the proposed merge of lp:~mfenniak/nunitv2/AppDomainUnloadFailure into lp:nunitv2.
=== modified file 'src/ClientUtilities/tests/DomainManagerTests.cs' --- src/ClientUtilities/tests/DomainManagerTests.cs 2010-04-19 03:57:21 +0000 +++ src/ClientUtilities/tests/DomainManagerTests.cs 2010-08-09 13:23:42 +0000 @@ -76,6 +76,16 @@ } return path; + } + + [Test] + public void UnloadUnloadedDomain() + { + AppDomain domain = AppDomain.CreateDomain("DomainManagerTests-domain"); + AppDomain.Unload(domain); + + DomainManager manager = new DomainManager(); + manager.Unload(domain); } } } === modified file 'src/ClientUtilities/util/Services/DomainManager.cs' --- src/ClientUtilities/util/Services/DomainManager.cs 2010-07-31 21:34:07 +0000 +++ src/ClientUtilities/util/Services/DomainManager.cs 2010-08-09 13:23:42 +0000 @@ -151,13 +151,23 @@ public void Unload() { - log.Info("Unloading AppDomain " + domain.FriendlyName); + string domainName; + try + { + domainName = domain.FriendlyName; + } + catch (AppDomainUnloadedException) + { + return; + } + + log.Info("Unloading AppDomain " + domainName); thread = new Thread(new ThreadStart(UnloadOnThread)); thread.Start(); if (!thread.Join(20000)) { - log.Error("Unable to unload AppDomain {0}, Unload thread timed out", domain.FriendlyName); + log.Error("Unable to unload AppDomain {0}, Unload thread timed out", domainName); thread.Abort(); } }
_______________________________________________ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp