在C#中尝试获取AD帐号信息时,会随机出现Attempted to access an unloaded appdomain的问题,解决方法如下:
将
principalContext = new PrincipalContext(ContextType.Domain)
替换为:principalContext = new PrincipalContext(ContextType.Domain,"MYDOMAIN")MYDOMAIN为对应的域名即可。