Relying on AppDomain.IsDefaultAppDomain()

Posted by lysergic-acid on Stack Overflow See other posts from Stack Overflow or by lysergic-acid
Published on 2012-07-08T09:12:45Z Indexed on 2012/07/08 9:15 UTC
Read the original article Hit count: 337

Filed under:
|
|
|

I have a component which should be initialized in a certain way ONLY on the main AppDomain.

On other AppDomains, it is initialized as a proxy to the object that lives in the main appdomain.

The component uses AppDomain.Current.IsDefaultAppDomain() to determine whether it is on the main appdomain or not.

My problem is that when running unit tests (NUnit), this method returns false, as the test runner initializes my test classes in a different app domain, causing the tests to not behave right.

How can this be resolved?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET