Search code examples
c#mobilecombroadband

Mobile Broadband C# interface to manage Profiles


I am trying to use the C# interface to the mobile broadband API. The code below compiles and intellisense displays all of the COM methods, but the code does not execute correctly.

MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnConnectionProfile conProfile = (IMbnConnectionProfile)mbnInfMgr;

string xmlBuff = conProfile.GetProfileXmlData();

The following error is produced:

Unable to cast COM object of type 'System.__ComObject' to interfacetype
'MbnApi.IMbnConnectionProfile'.
This operation failed because the QueryInterface call on the COM component
for the interface with IID '{DCBBBAB6-2010-4BBB-AAEE-338E368AF6FA}' failed
due to the following error:
No such interface supported(Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Microsoft lists the calls as below:

IMbnConnectionProfile Interface Method C# Signature

Delete              public void Delete();
GetProfileXmlData   public string GetProfileXmlData();
UpdateProfile       public void UpdateProfile( string strProfile);

It looks as if I need to specify the interface but can't seem to find out how to do this.

Can any one show me how to do this please?


Solution

  • By calling IMbnInterfaceManager::GetInterface or IMbnInterfaceManager::GetInterfaces methods.

    E.g.

    MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
    IMbnInterfaceManager infManager = (IMbnInterfaceManager)mbnInfMgr;
    
    //obtain the IMbnInterface passing interfaceID
    string interfaceID = “{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}”;
    
    IMbnInterface mbnInterface= infMgr.GetInterface(interfaceID);
    
    MbnConnectionProfileManager mbnProfMgr = new MbnConnectionProfileManager();
    IMbnConnectionProfileManager profileManager = 
                                      (IMbnConnectionProfileManager)mbnProfMgr;
    
    IMbnConnectionProfile[] profArr = 
    (IMbnConnectionProfile[])profileManager.GetConnectionProfiles(mbnInterface);