用于管理配置文件的移动宽带C#接口
我正在尝试将C#接口用于移动宽带API。下面的代码编译并显示所有COM方法,但代码执行不正确用于管理配置文件的移动宽带C#接口,c#,mobile,com,broadband,C#,Mobile,Com,Broadband,我正在尝试将C#接口用于移动宽带API。下面的代码编译并显示所有COM方法,但代码执行不正确 MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager(); IMbnConnectionProfile conProfile = (IMbnConnectionProfile)mbnInfMgr; string xmlBuff = conProfile.GetProfileXmlData(); 产生以下错误: Unable to cast C
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnConnectionProfile conProfile = (IMbnConnectionProfile)mbnInfMgr;
string xmlBuff = conProfile.GetProfileXmlData();
产生以下错误:
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)).
看起来好像我需要指定接口,但似乎无法找到如何执行此操作
谁能告诉我怎么做吗?通过调用或方法
例如
谢谢Jacob,我现在将尝试使用您的解决方案-非常感谢您花时间回答我的问题。我现在能够从每个接口读取xml文档的配置文件,但我无法编辑/修改,将引发一个异常,其中没有关于以下代码的详细信息。XDocument xdoc=XDocument.Parse(profArr[0].GetProfileXmlData()); xdoc.Add(新的XComment(“由系统修改”);你知道为什么会这样吗-谢谢
IMbnConnectionProfile Interface Method C# Signature
Delete public void Delete();
GetProfileXmlData public string GetProfileXmlData();
UpdateProfile public void UpdateProfile( string strProfile);
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);