2017-04-06 34 views
-1

我必须添加一项功能,允许用户从应用程序中修改系统卷。为此,我已使用CoreAudioApi.dll作为本网站其他问题中引用的内容。CoreAudioApi.dll在某些计算机上抛出COMException

例如How to programmatically set the system volume?

我已经加入到CoreAudioApi.dll

参考这工作我开发的计算机上正常,但是,当应用程序是别人的计算机上运行(如人测试它),我们得到以下例外:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in CoreAudioApi.dll 
A first chance exception of type 'Autofac.Core.DependencyResolutionException' occurred in Autofac.dll 
A first chance exception of type 'Autofac.Core.DependencyResolutionException' occurred in Autofac.dll 
A first chance exception of type 'Microsoft.Practices.ServiceLocation.ActivationException' occurred in Microsoft.Practices.ServiceLocation.dll 

两台PC都运行Windows 7,64位。

关于什么可能会导致此问题的任何想法?它是否引用另一个dll或可能碰巧有另一个dll或其他用户没有?

编辑

只是来缩小究竟发生异常......

private readonly MMDeviceEnumerator _deviceEnumerator = new MMDeviceEnumerator(); 
private readonly MMDevice _playbackDevice; 

public SettingsViewModel() 
{ 
    // The exception occurs in the following line: 
    _playbackDevice = _deviceEnumerator.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia); 

调试器将尝试(在情况下的信息是任何帮助)

+0

其他用户是他们机器上的管理员吗? – BugFinder

+0

@BugFinder - 我已经要求他们尝试以管理员身份运行,并没有区别。 – colmde

回答

0

至于进入ServiceLocatorImplBase.cs通常,我会花几个小时看一些东西,发表一个问题,然后直接打我。

另一台计算机的音频硬件似乎取决于扬声器或耳机插入之前,它甚至会启用自己。他们不是。 (由于我们的应用程序还没有添加声音,他依靠视频检查音量调音台来测试它。)当其他用户插入耳机时,一切正常。

我可以通过禁用音频硬件在我自己的PC上重现问题。看起来我只需要处理这个异常,并在这种情况下禁用UI控件。

相关问题