I have the following code snippet which calls a COM interface api (MS Mobile API)
try
{
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager infMgr = (IMbnInterfaceManager)mbnInfMgr;
IMbnInterface[] interfaces = (IMbnInterface[])infMgr.GetInterfaces();
///
/// NOTE: Will throw exception here if no Adapter Present - "Service not Started"
///
foreach (IMbnInterface mobileInterface in interfaces)
{
MBN_INTERFACE_CAPS caps = mobileInterface.GetInterfaceCapability();
MBN_READY_STATE readyState = mobileInterface.GetReadyState();
IMbnRadio radio = (IMbnRadio)mobileInterface;
MBN_PROVIDER provider = mobileInterface.GetHomeProvider();
///
/// NOTE: Will throw exception here if no SIM Present.
///
The COM Exceptions are handled as below
///
/// Handle COM Exceptions
///
catch (System.Runtime.InteropServices.COMException ex)
{
switch ((uint)ex.ErrorCode)
{
case 0x8054820A:
// ...
break;
case 0x80070490:
// ...
break;
default:
string str = "COM: " + ex.Message;
break;
}
}
The issue I have is that not all exceptions to my mind are are fatal, as in the 'No SIM' exception and I still require to access the COM interface components that have been created, but the exception terminates all those instances.
How should I go about this, or do I have to go through the construtor processs again ?
Thanks for any advice
Sarah T
User contributions licensed under CC BY-SA 3.0