Why am I getting a 0x8000500c error when enumerating a SearchResultCollection in .Net
问题 I am trying to enumerate the values in a SearchResultCollection. Everything compiles fine, but I get the 0x8000500c error on this line: foreach (PropertyValueCollection e in de.Properties.Values) { sw.WriteLine(e.Value); } Full method is below: private static void GetValues() { var directoryEntry = new DirectoryEntry("LDAP://8.8.8.8:8888", "foo", "bar", AuthenticationTypes.None); var ds = new DirectorySearcher(directoryEntry); var final = ds.FindAll(); var sw = new StreamWriter(@"C:\z\FooBar