.NET - NGEN compile x86 assembly

1

This is a followup to this question:

NGEN x86 vs x64 with .NET executables

I know that it's possible to NGEN using a custom setup action, but I use Inno Setup, so I have to do it manually.

The question: if my assembly is compiled in x86 mode, should I always use x86 version of ngen.exe, or depending on the OS (x86 ngen.exe on x86 Windows and x64 ngen.exe on x64 Windows)?

The problem is that I'm getting the following errors with NGEN installation:

Compiling assembly C:\Program Files\MyApp\MyApp.exe (CLR v4.0.30319) ... 01/15/2012 15:05:28 [2432]: 1>Error compiling C:\Program Files\MyApp\MyApp.exe: This version of is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher. (Exception from HRESULT: 0x800700D8)

Ideally, I'd like to compile into native code the main assembly (x86) and all its dependencies (mixed x86 and AnyCPU builds).

Please advise.

.net
compilation
x86
64-bit
ngen
asked on Stack Overflow Jan 15, 2012 by SharpAffair • edited May 23, 2017 by Community

2 Answers

1

I had similar issues with NSIS on IronScheme.

  1. In the installer determine the runtime (x86/x64)
  2. Then determine the framework version (2 or 4).
  3. Depending on above 2, run the appropriate NGEN executable

Link to NSIS script: https://github.com/leppie/IronScheme/blob/master/IronScheme/ironscheme.nsi

answered on Stack Overflow Apr 2, 2012 by leppie
0

I had the same problem when i tried to compile MyApp.exe with NGEN in AnyCPU mode. . . Then I switched x64 mode and it worked

answered on Stack Overflow Apr 2, 2012 by Taron Mehrabyan • edited Oct 28, 2012 by Nikhil

User contributions licensed under CC BY-SA 3.0