سؤال

When I try to get the list of available audio devices like this.

LyncClient client = LyncClient.GetClient();
foreach (Device dev in client.DeviceManager.AudioDevices)
{
      //Do something
}

I get the error Exception has been thrown by the target of an invocation.

"Unable to cast COM object of type 'System.__ComObject' to interface type 
'Microsoft.Office.Uc.IAudioDevice2'. This operation failed because the QueryInterface 
call on the COM component for the interface with IID '{86B3E5FE-4635-4C1E-
A725-C80B71D04984}' failed due to the following error: No such interface supported 
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

Here is the stack trace

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Microsoft.Lync.Model.Internal.UCWCache.CreateUCW(Object source, CCOMInfo ccomInfo)
at Microsoft.Lync.Model.Internal.UCWCache.GetITTargetNS(Object source)
at Microsoft.Lync.Model.Internal.UCEnumerator`2.get_Current()
at Microsoft.Lync.Model.Internal.UCEnumerator`2.System.Collections.Generic.IEnumerator<S>.get_Current()

And the inner exception stack trace

at Microsoft.Lync.Model.Device.AudioDevice.INTERNAL_Init(IAudioDevice initInterface)
at Microsoft.Lync.Model.Device.AudioDevice.INTERNAL_Init_Object(Object initInterface)
هل كانت مفيدة؟

المحلول

Did you check that both Lync and your SDK have the same version numbers?

There seems to be many releases of Lync 2013, and they may not have the same version.

نصائح أخرى

Problem appears to be in the "//Do something" part of the code.

I just ran he following fine.

 var Client = LyncClient.GetClient();

       foreach (var dev in Client.DeviceManager.AudioDevices)
       {               
           Console.WriteLine(dev.Name);
       }

Any chance of a stack trace if this doesn't work?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top