hresult from IMbnInterfaceManager::GetInterfaces when no MBN device exists

909 views Asked by At

I have the following code working in Windows 7:

            MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
            IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager;

            if (mbnInfMgrInterface != null)
            {
                IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[];
            }

No problems when the MBN device exists but when an MBN device doesn't exist I get the following exception in the call to GetInterfaces():

{System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490) at MbnApi.IMbnInterfaceManager.GetInterfaces() at foo.Program.configureConnection() in foo}

Question Is there something that should be done to check for a MBN interface before calling GetInterfaces? I can simply catch this exception but I can't find any documentation that says this exception is the same as having no interfaces.

The closest thing I have found on statckoverflow is this struggling with mobile broadband api windows 7 and windows 8 with C#, not sure what to install which implies that maybe windows 7 behaves differently than windows 8.1.

1

There are 1 answers

0
user8128167 On

I got the same Element not found exception trying to use GetSignalStrength() and MbnInterfaceManager I instead found you can obtain a lot of useful info using WMI. Please see the answer here using SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface:

struggling with mobile broadband api windows 7 and windows 8 with C#, not sure what to install

UPDATE:

Please note that I found you cannot get the network info in Windows 8.1 in the same way as you do in Windows 7. See How can I install an application that requires WMI capabilities on Windows 8.1 to determine available bandwidth? and https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201