Created
January 3, 2017 19:32
-
-
Save jbogard/c43f1f64a2f3c101621d4f5c1423acf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void FixEntryAssembly() | |
{ | |
// http://dejanstojanovic.net/aspnet/2015/january/set-entry-assembly-in-unit-testing-methods/ | |
AppDomainManager manager = new AppDomainManager(); | |
FieldInfo entryAssemblyfield = manager.GetType() | |
.GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic); | |
entryAssemblyfield?.SetValue(manager, typeof(Startup).Assembly); | |
AppDomain domain = AppDomain.CurrentDomain; | |
FieldInfo domainManagerField = domain.GetType() | |
.GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic); | |
domainManagerField?.SetValue(domain, manager); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment