I recently created this code for a WPF application that I was doing. The project where I'm reusing the code is a Windows 8 application. The code itself is the same so I don't really see what could be the issue. The only difference between them is of course the application and the .NET Framework being used. In the WPF application I was targeting .NET 3.0 and for the Windows 8 application I'm using .NET 4.5.
As you can tell this is an extension method:
public static bool isTunnel(this NetworkInterface adapter)
{
return adapter.NetworkInterfaceType == NetworkInterfaceType.Tunnel;
}
The error it gives for that method is:
Error 3 'System.Net.NetworkInformation.NetworkInterface' does not contain a definition for 'NetworkInterfaceType' and no extension method 'NetworkInterfaceType' accepting a first argument of type 'System.Net.NetworkInformation.NetworkInterface' could be found (are you missing a using directive or an assembly reference?)
Error 4 The name 'NetworkInterfaceType' does not exist in the current context
In my model class I'm having a similar issue. On this line:
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
it causes an error saying that the GetAllNetworkInterfaces() does not exist in NetworkInterface. Here's the exact error:
Error 15 'System.Net.NetworkInformation.NetworkInterface' does not contain a definition for 'GetAllNetworkInterfaces'
Is there something that I don't know about reusing code from WPF application in Windows 8 applications?
Update: Using the ianainterfacetype I was able to fix half of my extension methods because I was able to tell if they were Ethernet, Wireless, or Tunnel. I'm still searching for a way to tell if they were created by VirtualBox or VMware.
For those who want to know about the ianainterfacetype you can find info here.