在 x86 系统上编译 C# .NET x64 二进制文件
我有一个 C# 项目,其中包含对 ScintillaNET 的引用。不幸的是,ScintillaNET 喜欢检测机器的架构并根据运行的架构加载本机 DLL。这意味着我的项目必须预编译成x86和x64版本(由于上述检测,我无法使用任何CPU)。
问题是我的构建服务器仅支持 x86。有没有办法可以在 x86 机器上以 x64 模式编译 .NET 程序集?据我所知,切换只是强制计算机加载所需架构的程序集,并且实际上不会在编译时输出任何依赖于架构的代码,但是,当在构建服务器上的 Mono 2.10.6 下进行编译时,我收到诸如以下错误:
“错误 CS0016:无法写入文件‘ScintillaNet’,原因:AMD64”
我无法使用 CorFlags.exe 更改 PE 标头,因为这是基于 Linux 的构建服务器。有什么办法可以做到这一点吗?
I have a C# project which contains a reference to ScintillaNET. Unfortunately ScintillaNET likes to detect the architecture of the machine and loads the native DLL based on the running architecture. That means that my project must be pre-compiled into x86 and x64 versions (I can not use Any CPU due to the above detection).
The problem is that my build server is x86-only. Is there a way I can compile a .NET assembly in x64 mode on an x86 machine? As far as I am aware the toggle simply forces the computer to load the assembly for the required architecture and doesn't actually output any architecture-dependent code at compile-time, however, when compiling under Mono 2.10.6 on the build server I get errors such as:
"error CS0016: Could not write to file `ScintillaNet', cause: AMD64"
I can't use CorFlags.exe to change the PE headers as this is a Linux-based build server. Is there any way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终通过将项目切换回任何 CPU 来解决这个问题。由于无论 .NET 设置如何,Scintilla 都只能在本机体系结构中工作,因此我必须在我的计算机上将其作为 64 位运行。最初,我打算将架构强制为 32 位以进行“编辑并继续”,这导致对 Scintilla 如何检测架构的混乱。
实际上,Scintilla 将强制自身采用本机架构,但如果您在任何 CPU 下构建和运行,.NET 应用程序将正常工作。此外,由于我无法在 32 位模式下运行带有 Scintilla 的 .NET 应用程序(用于编辑并继续工作),因此在我的计算机上强制使用 64 位模式也没有任何优势。
I ended up solving this issue by switching the project back to Any CPU. Since Scintilla will only work in the native architecture regardless of .NET settings, I had to run it as 64-bit on my machine. Originally I had intended to force the architecture to 32-bit to get Edit and Continue and this lead to confusion to how Scintilla detected architectures.
In reality, Scintilla will force itself to the native architecture, but if you build and run under Any CPU the .NET application will work fine. In addition, since I can't run a .NET application w/ Scintilla in 32-bit mode (for Edit and Continue to work) I get no advantage to forcing 64-bit mode on my machine either.