使用 DirectX 播放音频时出现加载程序锁定异常

2024-03-24

我正在尝试使用 DirectX dll 播放音频文件。

  Audio.FromFile("Message 1.mp3").Play();

但检测到加载器锁异常,如下所示: 我不是分析堆栈跟踪的专家。如何分析和解决装载机锁问题?

检测到 LoaderLock

Message: DLL 'C:\Windows\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. 
Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

堆栈跟踪:

'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'E:\Modules\ToDoApp\bin\Release\ToDoApp.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC\Microsoft.DirectX.AudioVideoPlayback\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.AudioVideoPlayback.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ToDoApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x127c has exited with code 0 (0x0).
The thread 0x210 has exited with code 0 (0x0).
'ToDoApp.vshost.exe' (Managed): Loaded 'E:\Modules\ToDoApp\bin\Release\ToDoApp.exe', Symbols loaded.
The thread 0x15a8 has exited with code 0 (0x0).

Edit:我尝试禁用加载程序锁定异常。它使异常消失,但文件仍然无法播放。

有什么提示吗?


本质上,当前版本的 DirectX 与当前版本的 Visual Studio 不能很好地配合。

DirectX 9.0c 不能很好地与 Visual Studio 配合使用。您能做的就是完全防止抛出异常。为此:单击“调试”->“异常...”菜单项,打开“托管调试助手”项,然后取消选中“LoaderLock”标签旁边的框。

尽管这不是最复杂的方法,但实际上这在几次情况下救了我。更好的方法是使用 DirectX 10,但并非每个人都拥有 Vista 及更高版本。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 DirectX 播放音频时出现加载程序锁定异常 的相关文章

随机推荐