IPGlobalProperties.GetIPGlobalProperties
<p>I wrote a test app to get all active ports on my network. Did some searching and found this was the easiest way. So I tried it and it work just fine. I then wrote another socket app with a sever and client side. It's pretty basic, has a create sever, join server and refresh button to get the active servers. The only time this method gets called is when you press the refresh button. If I open up the application 3 or more times and create a server with connected clients by the 4th one this method starts giving me this (Unknown error (0xc0000001)) error. Any idea why this could happen? Funny thing is I never get this on the initial application, the one I opened first. I don't know if somehow it get's a lock on this or something.</p>

<p>The exception gets thrown at this line:</p>

<pre><code>IPEndPoint[] endPoints = properties.GetActiveTcpListeners();
</code></pre>

<p>Here's the method, it returns an object of List for all ports within a min and max range.</p>

<pre><code>public static List&lt;UserLocalSettings&gt; ShowActiveTcpListeners(int min, int max)
{
    List&lt;UserLocalSettings&gt; res = new List&lt;UserLocalSettings&gt;();
    try
    {
        IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
        IPEndPoint[] endPoints = properties.GetActiveTcpListeners();
        foreach (IPEndPoint e in endPoints)
        {
            if (e.Port &gt; (min - 1) &amp;&amp; e.Port &lt; (max + 1))
            {
                UserLocalSettings tmpClnt = new UserLocalSettings();
                tmpClnt.player_ip = e.Address.ToString();
                tmpClnt.player_port = e.Port;
                tmpClnt.computer_name = Dns.GetHostEntry(e.Address).HostName;
                res.Add(tmpClnt);
            }
        }

    }
    catch (Exception ex1)
    {
    }
    return res;
}
</code></pre>

<p>Here's a screen print of the exception:</p>

<p><a href="http://i.stack.imgur.com/bttxk.gif" rel="nofollow">http://i.stack.imgur.com/bttxk.gif</a></p>
