Autor Beitrag
Trombone
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26
Erhaltene Danke: 1



BeitragVerfasst: Mo 31.10.11 00:58 
Moin,
folgendes verstehe ich nicht:

Im Folgenden Code wird eine Verbindung zum AD-Server hergestellt. Ist dieser Server nicht aktiv oder besteht keine verbindung, sollte eigendlch der catch block ausgeführt werden. Wird er aber nicht, wieso nicht?
Ich bekomme vom Debugger die Meldung: COMException wurde nicht behandelt
Der Server ist nicht funktionstüchtig


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
          
      

            DirectoryEntry rootEntry = new DirectoryEntry(root);
            DirectorySearcher directorySearch = new DirectorySearcher(rootEntry, searchSyntax);

            try
            {

                SearchResultCollection result = directorySearch.FindAll();

                foreach (SearchResult child in result)
                {

                    string childPath = child.Path.ToString().Replace(root + "/""");
                    objects.Add(childPath, (String)child.Properties["cn"][0]);

                }

            }
            catch (DirectoryServicesCOMException e)
            {

                MessageBox.Show(
                    e.ToString(),
                    errorMessage,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }


Wie kann ich diese Exception behandeln? Wie kann ich eventuell direkt testen ob der Server aktiv ist?

Würde mich über Rat freuen!