2011-04-13 51 views
5

我正在嘗試播放和使用DirectX dll的音頻文件。使用DirectX播放音頻時的加載程序鎖定異常

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). 

編輯: 我嘗試禁用加載器鎖定異常。它使例外消失,但該文件仍然無法播放。

任何提示?

回答

5

本質上,DirectX的版本不與Visual Studio的當前版本打好。

的DirectX 9.0c不與Visual Studio發揮很好。你可以做的是防止異常被拋出。爲此:單擊Debug-> Exceptions ...菜單項,打開「Managed Debugging Assistant」項,並取消選中「LoaderLock」標籤旁邊的框。

這實際上救了我一對夫婦的場合儘管它已經不是最精細的方法。更好的方法是使用DirectX 10,但不是每個人都有Vista和更高版本。

+0

是的,我做了幾分鐘回來。異常不再拋出,但文件不再播放..! – Marshal 2011-04-13 13:39:22

+0

試試'var audio = Audio.FromFile(「C:\ sound1.mp3」,false)\\ False將autorun設置爲false,然後設置audio.Play()。還要確保引用了「Microsoft.DirectX.dll」和「Microsoft.DirectX.AudioVideoPlayback」。 – 2011-04-13 13:44:36

+0

還要確保已安裝DirectX 9.0 SDK更新,無需SDK更新,因爲音量始終設置爲類似-100的值,所以播放時出現問題。安裝更新並嘗試將音量設置爲0. – 2011-04-13 13:50:32