Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling a C# .NET x64 binary on an x86 system

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?

like image 823
June Rhodes Avatar asked Jan 23 '12 12:01

June Rhodes


1 Answers

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.

like image 132
June Rhodes Avatar answered Oct 13 '22 15:10

June Rhodes