14

目前,我遇到了一个我无法通过谷歌解决方案解决的问题。到目前为止没有任何效果。当我编译 Leap Motion 代码并导入 Naoqi C# 库时,它工作正常。当我实际尝试使用一行代码连接到机器人时,我的程序崩溃了。我的程序设置为为任何 CPU 构建。Leap 库和 NaoQi 库都引用了 .dll,并将 .dll 放置在 debug 文件夹和 project 文件夹中以便更好地衡量。我现在还不知道问题出在哪里。

这里有人可以弄清楚吗?我会很高兴得到这个工作。

这是第一条错误消息,然后它要求我中断或继续:

An unhandled exception of type 'System.BadImageFormatException' occurred in LeapCSharp.NET4.0.dll

Additional information: Could not load file or assembly 'naoqi-dotnet4, Version=1.14.0.218, Culture=neutral, PublicKeyToken=b9b4e24bd78100d6' or one of its dependencies. An attempt was made to load a program with an incorrect format.

无论哪种方式,程序都会崩溃。这是此时控制台日志中的文本:

'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\Grace\Documents\Visual Studio 2012\Projects\NaoLeap\NaoLeap\bin\Debug\NaoLeap.vshost.exe'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'
The thread 'vshost.NotifyLoad' (0x440) has exited with code 0 (0x0).
The thread '<No Name>' (0x1914) has exited with code 0 (0x0).
The thread '<No Name>' (0xa90) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1a08) has exited with code 0 (0x0).
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\Grace\documents\visual studio 2012\Projects\NaoLeap\NaoLeap\bin\Debug\NaoLeap.exe', Symbols loaded.
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll'
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\Grace\documents\visual studio 2012\Projects\NaoLeap\NaoLeap\bin\Debug\LeapCSharp.NET4.0.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in LeapCSharp.NET4.0.dll
An unhandled exception of type 'System.BadImageFormatException' occurred in LeapCSharp.NET4.0.dll
Additional information: Could not load file or assembly 'naoqi-dotnet4, Version=1.14.0.218, Culture=neutral, PublicKeyToken=b9b4e24bd78100d6' or one of its dependencies. An attempt was made to load a program with an incorrect format.
'NaoLeap.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'
The program '[3484] NaoLeap.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
The program '[3484] NaoLeap.vshost.exe: Program Trace' has exited with code 0 (0x0).

我尝试使用 fuslogvw。这是程序崩溃后刷新 fuslogvw 时失败程序集的两个日志报告。

1)

<meta http-equiv="Content-Type" content="charset=unicode-1-1-utf-8"><!-- saved from url=(0015)assemblybinder: --><html><pre>
*** Assembly Binder Log Entry  (2/1/2013 @ 7:24:49 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Users\Grace\Documents\Visual Studio 2012\Projects\NaoLeap\NaoLeap\bin\Debug\NaoLeap.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = Grace-PC\Grace
LOG: DisplayName = Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Grace/documents/visual studio 2012/Projects/NaoLeap/NaoLeap/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NaoLeap.vshost.exe
Calling assembly : System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: Start validating all the dependencies.
LOG: [Level 1]Start validating native image dependency mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
WRN: No matching native image found.

</pre></html>

2)

<meta http-equiv="Content-Type" content="charset=unicode-1-1-utf-8"><!-- saved from url=(0015)assemblybinder: --><html><pre>
*** Assembly Binder Log Entry  (2/1/2013 @ 7:24:50 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Users\Grace\Documents\Visual Studio 2012\Projects\NaoLeap\NaoLeap\bin\Debug\NaoLeap.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = Grace-PC\Grace
LOG: Where-ref bind. Location = C:\Users\Grace\Documents\Visual Studio 2012\Projects\NaoLeap\NaoLeap\bin\Debug\NaoLeap.exe
LOG: Appbase = file:///C:/Users/Grace/documents/visual studio 2012/Projects/NaoLeap/NaoLeap/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NaoLeap.vshost.exe
Calling assembly : (Unknown).
===
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().

</pre></html>
4

1 回答 1

34

无法加载文件或程序集 'naoqi-dotnet4

供应商的文档中可以清楚地看出,NAO 包含本机 C++ 代码,并且必须针对 x86(32 位代码)构建它。但是,您正在以 64 位模式运行主 EXE。BadImageFormatException 是结果,64 位进程无法加载包含 32 位本机代码的程序集。

右键单击您的 EXE 项目,属性,构建选项卡。将平台目标更改为“x86”。

于 2013-02-02T01:31:06.343 回答