简体   繁体   中英

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?

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

Eg

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM