Nant、Booc 和 x64
我有一个 .NET 项目,它始终由 32 位计算机构建/运行。 我买了一台新的 64 位计算机,正在尝试解决让它在那里工作的任务。 构建脚本位于 nant 中,有时我们使用 nant 任务编译一些 boo 代码。 boo 代码引用了我们的核心 DLL,它是在构建过程的早期从 C# 源代码构建的。
我尝试了两件事:将其构建为在 32 位模式下运行,并将其构建为在 64 位模式下运行。 通过在多个程序(包括 booc)上使用 corflags,我能够构建以 32 位模式构建的项目,但最终在运行时遇到了一堆下游问题。 所以我需要以 64 位模式构建它,我认为无论如何这是更好的选择。
根据nant/booc源代码,booc nant任务使用CLR的Process类在进程内调用booc.exe,因此(我认为)它应该从父进程继承32位或64位。 但这并不反映我所看到的。
这是我所做的:
- 调用 nant
- 使用 64 位版本的 powershell在我的任务中 指定的平台 =“x64”。 我觉得我不应该这样做,因为anycpu应该没问题,但它似乎有所作为。
这是我收到的错误:
[booc] Compiling 5 files to 'C:\dev\build\MyProjectBoo.dll'.
[booc] BCE0106: Failed to access the types defined in assembly 'MyProject, Version=5.5.0.0, Culture=neutral, PublicKeyToken=null' - (C:\dev\build\MyProject.dll):Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
[booc] is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
[booc] is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
[booc] .
[booc] 1 error(s).
根据 booc 源代码,这意味着“我试图反思性地列出引用的程序集中的类型,但失败了”。 我不知道这是否意味着“我认为我是 32 位,但这些是 64 位 dll”或者什么,我很困惑。
关于如何让它发挥作用有什么想法吗?
更新 经过一些工作,我发现这个问题与 boo 无关。 我编写了一个快速的 C# 程序,它以反射方式加载 dll,并且以相同的方式中断。 因此,出于某种原因,无论我将平台设置为什么(x86、x64 或任何cpu),我都无法在 x64 机器上反射加载它。 所以这并不是boo的错。 因此,如果我有更好的问题,我将深入研究并重新发布。
更新 事实证明,我的主要 DLL 的第三方依赖项之一坚持处于 32 位环境中,即使它不是使用 corflags 构建的。 这会导致 assembly.GetTypes() 在 64 位模式下失败。
I have a .NET project that's always been built/run by/on 32 bit machines. I got a new a 64 bit computer and am trying to tackle the task of getting it working there. The build script is in nant, and at one point we compile some boo code using the nant task. The boo code references our core DLL, which is built from c# source earlier in the build process.
I've tried two things: build it to run in 32bit mode and build it to run in 64bit mode. By using corflags on several programs (including booc), I was able to build the project built in 32bit mode, but ended up with a bunch of downstream issues at runtime. So I need to get it built in 64bit mode, which I think is preferable anyway.
According to the nant/booc source code, the booc nant task calls the booc.exe in-process using the CLR's Process class, so (I think) it should inherit 32bitness or 64bitness from the parent process. That doesn't reflect what I'm seeing, though.
Here's what I've done:
- Used the 64bit version of powershell to invoke nant
- Specified platform="x64" on my tasks. I feel like I shouldn't have to do this because anycpu should be fine, but it seems to make a difference.
Here's the error I'm getting:
[booc] Compiling 5 files to 'C:\dev\build\MyProjectBoo.dll'.
[booc] BCE0106: Failed to access the types defined in assembly 'MyProject, Version=5.5.0.0, Culture=neutral, PublicKeyToken=null' - (C:\dev\build\MyProject.dll):Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
[booc] is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
[booc] is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
[booc] .
[booc] 1 error(s).
Which means, according to the booc source code, "I tried to reflectively list the types in your referenced assembly but failed". I don't know if that means, "I think I'm 32bit but these are 64bit dlls" or what, and I'm very confused.
Any ideas on how I can get this to work?
Update after some work, I've discovered that the issue has nothing to do with boo. I wrote a quick c# program that reflectively loads the dll and it breaks in the same way. So for some reason, no matter what I set as the platform (x86, x64 or anycpu), I can't load it reflectively on an x64 machine. So not really boo's fault. So I'm going to dig into this and repost if I have a better question.
Newer Update
Turns out that one of my main DLL's third party dependencies insists on being in a 32 bit environment, even though it isn't built with corflags. This causes assembly.GetTypes() fail in 64 bit mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于对需要 32 位模式的第三方 DLL 的依赖,即使它们没有设置 corflags,这也是可能的。
The problem is dependencies on third-party DLL's that require 32 bit mode, which is possible even if they don't have corflags set.