2014-10-12 275 views
1

操作系統:Windows 8.1 64無法加載文件或程序集X或其某個依賴項。不是有效的Win32應用程序。 (HRESULT:0x800700C1)

我試圖用DirectX在VB.Net中播放多個聲音,在我的代碼中沒有錯誤。 問題是每當事件觸發我得到這個錯誤

System.BadImageFormatException was unhandled Message: An unhandled exception of type 'System.BadImageFormatException' occurred in System.Windows.Forms.dll Additional information: Could not load file or assembly 'Microsoft.DirectX.AudioVideoPlayback.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

然後我設定的目標的CPU x86和我得到這個錯誤

System.IO.FileLoadException was unhandled Message: An unhandled exception of type 'System.IO.FileLoadException' occurred in System.Windows.Forms.dll Additional information: Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

到目前爲止,我已經嘗試卸載,重新安裝的DirectX SDK,安裝與DirectX和不同聲音文件(.wav)有關的所有內容。 此外,我不得不瀏覽加載.dlls,我找不到它們在參考管理器>組件,但現在我甚至不能通過瀏覽加載它們,所以我使用Imports Microsoft.DirectX.AudioVideoPlayback 它會讓我導入其餘.dlls除了(引用管理器甚至不會打開它們):

Microsoft.DirectX.AudioVideoPlayback.dll 
Microsoft.DirectX.dll 
Microsoft.DirectX.DirectSound.dll 

我需要的那些。有沒有辦法清理重新安裝它們?

Target Framework: .Net Framework 4.5

CODE:

Dim MySound1 As New Microsoft.DirectX.AudioVideoPlayback.Audio("D:\path\sound_file.mp3") 

MySound1.Play() 

讓我知道如果你需要知道的一切。

UPDATE: 我改變了Target Framework.Net Framework 3.5,它工作正常,但只有在CPU Target設置爲x86!這是爲什麼?

+0

糟糕的圖像聲音對我來說可能是聲音file.did你嘗試並使用其他聲音文件。或mybe嘗試一個.wav – Creator 2014-10-12 14:58:38

+0

'BadImageFormatException'通常是一個32位/ 64位問題。 DirectX庫是否與您的應用程序相同? – pmcoltrane 2014-10-12 15:28:51

+0

試過一個.wav文件 - 沒有工作。我將目標CPU設置爲x86,現在出現此錯誤: ***「System.IO.FileLoadException未處理 消息:在System.Windows.Forms.dll中發生未處理的類型爲」System.IO.FileLoadException「的異常。信息:混合模式程序集是針對運行時版本「v1.1.4322」構建的,無法在4中加載。0運行時>沒有額外的配置信息。「*** – 21CmOfPain 2014-10-12 17:31:10

回答

4

您正在使用olden Managed DirectX包裝。目標是在.NET 1.1上運行,這是一個從不支持64位代碼的框架版本。這些包裝很久以前就被棄用了,2.0版本從來沒有超出測試版。

需要將EXE的Platform Target更改爲x86,沒有64位版本的Managed DirectX,並且這些DLL包含以Managed C++編寫的本機32位代碼。此外,如果您的目標是.NET 4.0或更高版本,那麼您必須使用.config文件,該文件聲明加載如此古老的程序集可以在.NET 1.1上運行良好的古代程序集是可以的。它應該是這樣的:

<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0"/> 
    </startup> 
</configuration> 

useLegacyV2RuntimeActivationPolicy屬性可以禁止你得到了錯誤信息。它是否可以真正運行在4.0+上還不是很清楚,沒有人再使用這些包裝。通常的建議是切換到SharpDX或SlimDX。

+0

.config文件不起作用我得到另一個錯誤「HResult = -2146232799」,關於混合裝配,我想我會切換到SharpDX,謝謝。 – 21CmOfPain 2014-10-12 20:53:29

相關問題