Hi guys,
I've just noticed that some of the last commits (perhaps this one https://github.com/MonoGame/MonoGame/pull/5949 ) broke the audio support for Windows 7.
I've removed catches for try-catch blocks in the internal static void InitializeSoundEffect() and caught this exception: System.DllNotFoundException: Unable to find XAudio2 dlls for requested versions [2.7, 2.8 or 2.9], not installed on this machine.
Stacktrace:
at XAudio2..ctor(flags, processorSpecifier, requestedVersion)
at SoundEffect.InitializeSoundEffect()
(file: (...)\MonoGame.Framework\Audio\SoundEffect.XAudio.cs line: 149)
at FrameworkDispatcher.Initialize()
(file: (...)\MonoGame.Framework\FrameworkDispatcher.cs line: 42)
at FrameworkDispatcher.Update()
(file: (...)\MonoGame.Framework\FrameworkDispatcher.cs line: 27)
Regards!
I've investigated it a little more and turns out you're using SharpDX.XAudio2.dll (from SharpDX 4.0.1) which is compiled without DESKTOP_APP flag. As you can see in SharpDX.XAudio2.XAudio2 class source code this flag is required for locating XAudio2 DLL version 2.7 (for Windows 7).
So MonoGame from develop branch now ships with SharpDX.XAudio2.dll which is not compatible with Windows 7.
cc @Jjagg @tomspilman
Thanks for the heads up. We should use the desktop assembly. I'll fix this.
Thanks @Jjagg !
I will fix this on SharpDX and submit PR there
Submitted patch on SharpDX repository.
@aienabled - How does https://github.com/sharpdx/SharpDX/pull/943 fix this issue? We already merged a fix for this by using the right assembly for desktop projects (see https://github.com/MonoGame/MonoGame/pull/5989).
@Jjagg ?
The patch would make it so the missing fallback code is also in the .NET Standard assembly, so we could revert my quick fix and go back to having only the netstandard XAudio assembly.
Analogous to this issue, I think some versions of XInput won't be checked in the netstandard assembly. That would essentially unfix #3240.
Another related issue is that because of some APIs that are included in the assemblies we use, but excluded when building for UWP specifically, Windows 10 store certification may fail.
Not sure what the best solution here is because I don't know enough about Windows APIs, store certification and SharpDX. We could of course just use the specific assemblies for all dependencies, to be safe.
@amerkoleci do you know more about this? And thanks for the help :)
Just pushed XInput fix on SharpDX side
Hey guys, sorry to comment on a closed issue but I was wondering if you guys know if this fix has made it to sharpdx's nuget yet?
We have our own branch of monogame that has this issue (ts about 4 months behind master...) and we updated its sharpdx to 4.1.0-ci184 but we are still getting the issue on windows 7 machines.
Should I just merge in #5989 to fix this?
@Danthekilla Yes, that should fix it. That PR switches from the .NET Standard assembly of SharpDX to the .NET Framework 4.5 assembly. The latter has code (or rather had, I think that's been changed in develop fro SharpDX) that's conditionally compiled to check for an older version of XAudio not supported in the .NET Standard assembly.
I merged that in and made sure the dependencies were up to date but the issue still persists.
I made sure to clean and rebuild the monogame.framework.windows. Any ideas?
This is how my dependency's look currently, see any issues?

That looks to be correct. Windows 7 comes with XAudio 2.7, which is clearly loaded in the code for 4.0.1 (the DESKTOP_APP symbol is defined for the .NET 4.5 build): https://github.com/sharpdx/SharpDX/blob/v4.0.1/Source/SharpDX.XAudio2/XAudio2.cs#L88-L99
So I don't really know where this fails :/
A good next step would be to verify that the machine you're testing on supports XAudio 2.7. If that checks out and you're 100% you have the right assembly, I'm not sure what to do next.
A good next step would be to verify that the machine you're testing on supports XAudio 2.7
That is a good point. I had assumed that XAudio 2.7 would be fully supported in Win7 SP1, could I be missing some directx updates, I thought that since windows 7 DirectX was a core part of windows and not shipped / updated separately.
Most helpful comment
Just pushed XInput fix on SharpDX side