Wajahat Kareem
Wajahat Kareem

Reputation: 325

Windows 7 Default Network Adapter

Following is my code to get the default NIC in Windows XP, but the same code doesn't work in Windows 7. It's really confusing after reading MSDN. Any solution?

//----------------- Getting all the Nic's --------------------
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
    //------------ Getting properties of IPV4 ----------------
    IPInterfaceProperties ipProps = nic.GetIPProperties();

    //------------ Getting the Ip Properties -----------------
    if (ipProps.GetIPv4Properties() != null)
    {
        dic.Add(ipProps.GetIPv4Properties().Index, nic.Name);
    }

Error: The request protocol is not configured, or has no implementation.

Upvotes: 3

Views: 378

Answers (1)

favoretti
favoretti

Reputation: 30167

It means you are hitting interface without IPv4 support on it. Check for it with:

if (nic.Supports(NetworkInterfaceComponent.IPv4)) // means IPv4 support is present

See here for more.

Upvotes: 2

Related Questions