jjzjj

c# - "A first chance exception of type ' System.BadImageFormatException ' "在 64 位计算机上构建后

coder 2023-11-11 原文

我的 Visual Studio 2010 解决方案有 C DLL 和调用 C DLL 的 C# 项目。 在 32 位 Windows-7 Pro 计算机上构建时解决方案工作正常。 在 64 位 Windows-7 Pro 上,构建正常,但运行时,C# 调用 DLL 中的函数并出现错误:

A first chance exception of type 'System.BadImageFormatException'

解决方案配置管理器设置为:

<DLL project>   Platform = Win32       (<<< no option to change to "Any CPU")
<C# project>    Platform = "Any CPU"

下面的输出是:

  1. C DLL 构建输出

  2. C# 构建输出

  3. 运行输出

C DLL 构建输出:

1>------ Rebuild All started: Project: Ultrasound_Frame_Grabber, Configuration: Debug Win32 ------
1>  Processing ..\..\..\include\USGFWSDK\include\Usgfw2.idl
1>  Usgfw2.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oaidl.idl
1>  oaidl.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.idl
1>  objidl.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.idl
1>  unknwn.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wtypes.idl
1>  wtypes.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\basetsd.h
1>  basetsd.h
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\guiddef.h
1>  guiddef.h
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ocidl.idl
1>  ocidl.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oleidl.idl
1>  oleidl.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\servprov.idl
1>  servprov.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\urlmon.idl
1>  urlmon.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\msxml.idl
1>  msxml.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\strmif.idl
1>  strmif.idl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\control.odl
1>  control.odl
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oaidl.acf
1>  oaidl.acf
1>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ocidl.acf
1>  ocidl.acf
1>  stdafx.cpp
1>  DIBSectn.cpp
1>  sample.cpp
1>  sampleDlg.cpp
1>  Ultrasound_Frame_Grabber.cpp
1>  Generating Code...
1>  Usgfw2_i.c
1>  .NETFramework,Version=v4.0.AssemblyAttributes.cpp
1>     Creating library C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\Debug\Ultrasound_Frame_Grabber.lib and object C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\Debug\Ultrasound_Frame_Grabber.exp
1>strmbasd.lib(mtype.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>  sample.vcxproj -> C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\Debug\Ultrasound_Frame_Grabber.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

2) C# 构建输出:

1>------ Skipped Rebuild All: Project: VNMath, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Skipped Rebuild All: Project: GuiManager, Configuration: Debug Any CPU ------
2>Project not selected to build for this solution configuration 
3>------ Rebuild All started: Project: Ultrasound_Frame_Grabber, Configuration: Debug Win32 ------
4>------ Skipped Rebuild All: Project: VNCommon, Configuration: Debug Any CPU ------
4>Project not selected to build for this solution configuration 
5>------ Skipped Rebuild All: Project: AudioUtility, Configuration: Debug Any CPU ------
5>Project not selected to build for this solution configuration 
6>------ Skipped Rebuild All: Project: VNDevices, Configuration: Debug Any CPU ------
6>Project not selected to build for this solution configuration 
7>------ Skipped Rebuild All: Project: SimpleRPC, Configuration: Debug Any CPU ------
7>Project not selected to build for this solution configuration 
8>------ Skipped Rebuild All: Project: VNSockCommunication, Configuration: Debug Any CPU ------
8>Project not selected to build for this solution configuration 
9>------ Skipped Rebuild All: Project: PdfSharp, Configuration: Debug Any CPU ------
9>Project not selected to build for this solution configuration 
10>------ Skipped Rebuild All: Project: VNUserControls, Configuration: Debug Any CPU ------
10>Project not selected to build for this solution configuration 
11>------ Skipped Rebuild All: Project: GuiServer, Configuration: Debug Any CPU ------
11>Project not selected to build for this solution configuration 
3>  Processing ..\..\..\include\USGFWSDK\include\Usgfw2.idl
3>  Usgfw2.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oaidl.idl
3>  oaidl.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.idl
3>  objidl.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.idl
3>  unknwn.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wtypes.idl
3>  wtypes.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\basetsd.h
3>  basetsd.h
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\guiddef.h
3>  guiddef.h
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ocidl.idl
3>  ocidl.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oleidl.idl
3>  oleidl.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\servprov.idl
3>  servprov.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\urlmon.idl
3>  urlmon.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\msxml.idl
3>  msxml.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\strmif.idl
3>  strmif.idl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\control.odl
3>  control.odl
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\oaidl.acf
3>  oaidl.acf
3>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ocidl.acf
3>  ocidl.acf
3>  stdafx.cpp
3>  DIBSectn.cpp
3>  sample.cpp
3>  sampleDlg.cpp
3>  Ultrasound_Frame_Grabber.cpp
3>  Generating Code...
3>  Usgfw2_i.c
3>  .NETFramework,Version=v4.0.AssemblyAttributes.cpp
3>     Creating library C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\Debug\Ultrasound_Frame_Grabber.lib and object C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\Debug\Ultrasound_Frame_Grabber.exp
3>strmbasd.lib(mtype.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
3>  sample.vcxproj -> C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\Debug\Ultrasound_Frame_Grabber.dll
12>------ Rebuild All started: Project: MY_APP, Configuration: Debug Any CPU ------
C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\MY_APP\FrmMY_APP.cs(291,4): warning CS0162: Unreachable code detected
C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\MY_APP\FrmMY_APP.cs(441,4): warning CS0164: This label has not been referenced
C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\MY_APP\FrmMY_APP.cs(1276,13): warning CS0219: The variable 'exportFrmIsUp' is assigned but its value is never used
C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\MY_APP\FrmMY_APP.cs(91,66): warning CS0067: The event 'VN.Forms.MY_APPForm.m_eventTabletConnectionStatusChanged' is never used

Compile complete -- 0 errors, 4 warnings
12>  MY_APP -> C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\MY_APP\bin\Debug\MY_APP.exe
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\Common.Logging.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\Common.Logging.Log4Net.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\DistributedFileSystem.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\ICSharpCode.SharpZipLib.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\libMobiledevice.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\log4net.config
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\log4net.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\NetworkCommsDotNet.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\protobuf-net.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\QuickLZCompressor.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\SerializerBase.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\SevenZipLZMACompressor.dll
12>  C:\Primary\PROJECTS\my_project\WORK\Win7 VPS\\CommsLibrary\SharpZipLibCompressor.dll
12>         13 file(s) copied.
========== Rebuild All: 2 succeeded, 0 failed, 10 skipped ==========

3) 运行输出:

'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.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', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.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', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.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.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\MY_APP.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.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', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.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', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.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', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceProcess\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ServiceProcess.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MY_APP.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', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.NotifyLoad' (0x197c) has exited with code 0 (0x0).
The thread '<No Name>' (0x838) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1744) has exited with code 0 (0x0).
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\MY_APP.exe', Symbols loaded.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\VN.Common.dll', Symbols loaded.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\GuiServer.dll', Symbols loaded.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\GuiManager.dll', Symbols loaded.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\VNUserControls.dll', Symbols loaded.
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Primary\PROJECTS\VasoNova\WORK\Win7 VPS\MY_APPG4\bin\Debug\VNSockCommunication.dll', Symbols loaded.

通信步骤 0:MY_APPForm_Load。我的应用程序现在调用 DLL 中的 C 函数,这会导致此错误:

A first chance exception of type 'System.BadImageFormatException' occurred in MY_APP.exe

最佳答案

Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib...

您的程序作为 64 位进程运行。您的 DLL 包含 32 位非托管代码。轰隆隆。

您需要强制您的 EXE 作为 32 位进程运行,以便可以加载 DLL。在“解决方案资源管理器”窗口中右键单击您的 EXE 项目。 Properties,Build 选项卡,将 Platform target 设置从 AnyCPU 更改为 x86。在 VS2012 及更高版本上勾选“首选 32 位”选项。重复发布配置。

关于c# - "A first chance exception of type ' System.BadImageFormatException ' "在 64 位计算机上构建后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18625394/

有关c# - "A first chance exception of type ' System.BadImageFormatException ' "在 64 位计算机上构建后的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  4. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  5. ruby - 什么是填充的 Base64 编码字符串以及如何在 ruby​​ 中生成它们? - 2

    我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%

  6. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  7. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

    我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

  8. ruby - 在 jRuby 中使用 'fork' 生成进程的替代方案? - 2

    在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',

  9. ruby - 主要 :Object when running build from sublime 的未定义方法 `require_relative' - 2

    我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby​​1.9+ 关于ruby-主要:Objectwhenrun

  10. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

随机推荐