无法加载文件或程序集X或它的一个依赖。是不是有效的Win32应用程序。 (HRESULT:0x800700C1) [英] Could not load file or assembly X or one of its dependencies. is not a valid Win32 application. (HRESULT: 0x800700C1)

查看:5913
本文介绍了无法加载文件或程序集X或它的一个依赖。是不是有效的Win32应用程序。 (HRESULT:0x800700C1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Windows 8.1 64

OS: Windows 8.1 64

我试图扮演多个声音在VB.Net与DirectX,也有我的code没有错误。 现在的问题是每当事件触发我得到这个错误

I tried to play multiple sounds in VB.Net with DirectX, there are no errors in my code. The problem is whenever the event is fired I get this error

System.BadImageFormatException是未处理消息:未处理   异常类型System.BadImageFormatException'的发生   System.Windows.Forms.dll的其他信息:无法加载文件   或组装Microsoft.DirectX.AudioVideoPlayback.dll或它的一个   依赖性。是不是有效的Win32应用程序。 (异常来自   HRESULT:0x800700C1)

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和我得到这个错误

Then I set Target CPU to x86 and I got this error

System.IO.FileLoadException是未处理消息:未处理   异常类型System.IO.FileLoadException的发生   System.Windows.Forms.dll的更多信息:混合模式总成   是建立针对运行时的版本V1.1.4322',不能   在4.0运行时加载,无需额外配置   信息。

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)。 此外,我不得不浏览加载.dll,可我找不到他们在引用管理>程序集,但现在我不能甚至通过浏览加载它们,所以我用进口Microsoft.DirectX.AudioVideoPlayback 这将让我导入其余的.dll除非(参考经理甚至不会打开它们):

So far I have tried uninstalling-reinstalling DirectX SDK, Installing everything that has to do with DirectX and different sound files (.wav). Also I had to browse to load the .dlls, I couldn't find them under Reference Manager>Assemblies but now I cant even load them through browse so I use Imports Microsoft.DirectX.AudioVideoPlayback It will let me Import the rest .dlls except(Reference Manager wont even open them):

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

这是我需要的。有没有一种方法来清洁重新安装呢?

the ones that I need. Is there a way to clean re-install them?

目标框架:.Net框架4.5

Target Framework: .Net Framework 4.5

code:

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

MySound1.Play()

让我知道如果你需要知道的任何东西。

Let me know if you need to know anything else.

更新: 我改变了目标框架 .NET Framework 3.5的,它工作正常,但只有当 CPU目标设置为 86 !这是为什么呢?

UPDATE: I changed the Target Framework to .Net Framework 3.5 and it works fine but only if the CPU Target is set to x86! Why is that?

推荐答案

您使用的是古代托管DirectX 包装。有针对性地对.NET 1.1中运行,从来没有支持64位code的框架版本。这些包装已经去precated很久以前,在2.0版本就再也没有完成测试。

You are using the olden Managed DirectX wrappers. Targeted to run on .NET 1.1, a framework version that never supported 64-bit code. These wrappers have been deprecated a long time ago, the 2.0 version never made it out of beta.

更改您的EXE的目标平台的x86是必需的,没有64位版本的托管DirectX和dll包含原生32位code写的托管C ++。此外,如果你的目标。NET 4.0或更高版本,那么你必须使用一个config文件,指出它是好的加载这样一个古老的大会,预计本地code到.NET 1.1上运行良好。它应该是这样的:

Changing your EXE's Platform Target to x86 is required, there is no 64-bit version of Managed DirectX and the DLLs contain native 32-bit code written in Managed C++. Furthermore, if you target .NET 4.0 or higher then you have to use a .config file that says that it is okay to load such an ancient assembly that expects native code to run well on .NET 1.1. It should look like this:

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

useLegacyV2RuntimeActivati​​onPolicy 的属性燮presses你得到了错误的信息。是否能在4.0+实际运行并不清楚,没有人使用这些包装了。通常的建议是切换到SharpDX或SlimDX代替。

The useLegacyV2RuntimeActivationPolicy attribute suppresses the error message you got. Whether it can actually run on 4.0+ isn't that clear, nobody uses these wrappers anymore. The usual advice is to switch to SharpDX or SlimDX instead.

这篇关于无法加载文件或程序集X或它的一个依赖。是不是有效的Win32应用程序。 (HRESULT:0x800700C1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆