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

| 我正在尝试使用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).
编辑: 我尝试禁用加载程序锁定异常。它使异常消失,但仍然无法播放文件。 有什么提示吗?     
已邀请:
本质上,当前版本的DirectX不能与当前版本的Visual Studio很好地配合使用。 DirectX 9.0c在Visual Studio中不能很好地播放。您可以做的是完全防止引发异常。为此,请执行以下操作:单击Debug-> Exceptions ...菜单项,打开\“ Managed Debugging Assistant \”项,然后取消选中\“ LoaderLock \”标签旁边的框。 尽管这不是最复杂的方法,但实际上确实使我节省了很多次。更好的方法是使用DirectX 10,但并非每个人都具有Vista及更高版本。     
“ѭ3”是Managed DirectX的已知错误。您可以通过在托管调试助手下的Visual Studio例外列表中将其禁用来解决此问题。 更好的解决方法是切换到受支持的DirectX库,例如SlimDX或XNA。     

要回复问题请先登录注册