Problems with network interfaces
-
I'm writing a program that needs to list all network interfaces in the computer and detects their speed. I tried performance counter related classes in Diagnosis namespace, but many unexpected problems occured. can someone tell me how to do it right? any advice appreciated.
-
I'm writing a program that needs to list all network interfaces in the computer and detects their speed. I tried performance counter related classes in Diagnosis namespace, but many unexpected problems occured. can someone tell me how to do it right? any advice appreciated.
Um, why don't you tell us what problems occured. Exception messages, incorrect behavior versus expected behavior, and stuff like that. Ever try to provide support to someone saying only "I have a problem"?
Microsoft MVP, Visual C# My Articles
-
Um, why don't you tell us what problems occured. Exception messages, incorrect behavior versus expected behavior, and stuff like that. Ever try to provide support to someone saying only "I have a problem"?
Microsoft MVP, Visual C# My Articles
First, I don't know the correct way to enumerate network interfaces on a computer, so I used existing performance counters, and calculate the network speed in a brute forcing manner. One problem is that a "MS TCP loopback interface" exists on every computer. I gave my program to some friends, and they told me it won't work with dial up network and some ADSL network, so I don't know the exact exception message.
-
First, I don't know the correct way to enumerate network interfaces on a computer, so I used existing performance counters, and calculate the network speed in a brute forcing manner. One problem is that a "MS TCP loopback interface" exists on every computer. I gave my program to some friends, and they told me it won't work with dial up network and some ADSL network, so I don't know the exact exception message.
Then why don't you ask them. Something else you should look into is WMI, which uses the
System.Management
namespace for classes in .NET. There is aWin32_NetworkAdapter
WMI class that allows you to get all the information for adapters. Even my WAN interfaces show up when querying the class for instances. You can use the mgmtclassgen.exe utility that comes with the .NET Framework SDK to generate a class file (not an assembly like the interop utilities do), or download and install the WMI Extensions for Visual Studio .NET 2002[^], which allows you to browse all the classes and even generate source files in your project. For more information, look up theSystem.Management
namespace in your help documentation for the .NET Framework SDK (or the Visual Studio Combined Collection), or read the following article, System.Management Lets You Take Advantage of WMI APIs within Managed Code[^].Microsoft MVP, Visual C# My Articles
-
Then why don't you ask them. Something else you should look into is WMI, which uses the
System.Management
namespace for classes in .NET. There is aWin32_NetworkAdapter
WMI class that allows you to get all the information for adapters. Even my WAN interfaces show up when querying the class for instances. You can use the mgmtclassgen.exe utility that comes with the .NET Framework SDK to generate a class file (not an assembly like the interop utilities do), or download and install the WMI Extensions for Visual Studio .NET 2002[^], which allows you to browse all the classes and even generate source files in your project. For more information, look up theSystem.Management
namespace in your help documentation for the .NET Framework SDK (or the Visual Studio Combined Collection), or read the following article, System.Management Lets You Take Advantage of WMI APIs within Managed Code[^].Microsoft MVP, Visual C# My Articles