NAudio device enumeration stops working when combined with AudioSwitcher
See original GitHub issueWith NAudio commit 420e607 or NAudio NuGet version 1.8.5, I receive the following exception, when trying to create a new instance of MMDeviceEnumerator.
System.InvalidCastException: ‘Unable to cast object of type ‘System.__ComObject’ to type ‘NAudio.CoreAudioApi.Interfaces.MMDeviceEnumeratorComObject’.’
The problem occurs if calling the following code:
var coreAudioController = new AudioSwitcher.AudioApi.CoreAudio.CoreAudioController();
var deviceEnumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();
The problem does not occur if calling the following code:
var deviceEnumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();
It appears that AudioSwitcher interferes with the creation of the NAudio.CoreAudioApi.Interfaces.MMDeviceEnumeratorComObject object that NAudio uses for device enumeration.
Since this problem only occurs when using both AudioSwitcher (Version 3.0.0) and NAudio, I don’t know if this is the correct place to report the problem or if I should post it in the AudioSwitcher project.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top GitHub Comments
Same problem but i solved it. The AudioSwitcher.AudioApi.CoreAudio has conflict with NAudio.CoreAudioApi, you need to switch the order. set the AudioSwitcher.AudioApi.CoreAudio under the NAudio.CoreAudioApi.
@snippyy Same problem here, but what exactly do you mean by “set the AudioSwitcher.AudioApi.CoreAudio under the NAudio.CoreAudioApi.”
Can you give me a hint please.