I sometimes write applications and/or libraries which need the LARGE_ADDRESS_AWARE-flag set. I usually solve this by calling editbin.exe as postbuild-event.
Would it be an good idea to add a corresponding switch directly to the C#/F#/.... compiler?
It would have the following pros:
_Or am I the sole one appending the editbin-postbuild to every second project of mine?_
This is already implemented:
Thanks, @sharwell. That's a very simple workaround.
How does it work when you're compiling for .NET Native though, where one must choose a CPU architecture rather than "any cpu"?
I agree, there should be a way to explicitly set these PE header flags as part of the compilation.
@AArnott I've never used .NET Native. Sounds like a bug should be filed there to work with Any CPU outputs.
@sharwell, it also seems like a bug that you cannot set LAA for explicit x86, but it magically gets set for AnyCPU/Prefer32Bit.
There are native libraries you could potentially be interoping with that are not LAA, and will fail with that assumption.
There are also cases where you are explicitly targeting x86 because AnyCPU is invalid (explicit x86 prevents the binary from being loaded in a 64-bit processes, AnyCPU+Prefer32Bit does not) but where you may still want LAA.
I'm not sure if .NET Native has a bug or not. I was just wondering about that scenario.
+1 to @tannergooding's points. We compile with x86 sometimes because we know we'll be loading x86 native binaries, so x64 is not an option. The compiler/build knows this and will actually emit warnings if we reference x86 assemblies while targeting AnyCPU ourselves. So yes, there should be a way to require x86 and still be LAA.
From the header I understand that this also might affect dll libraries. We create various vsto applications which should ship as anycpu if possible since some users have excel, word or outlook 32-bit and some 64-bit.
Is there a good way to have these libraries also run in Excel versions with LAA and use the memory advantage, without loosing the option to use them with 64-bit office?
Most helpful comment
@sharwell, it also seems like a bug that you cannot set LAA for explicit x86, but it magically gets set for AnyCPU/Prefer32Bit.
There are native libraries you could potentially be interoping with that are not LAA, and will fail with that assumption.
There are also cases where you are explicitly targeting x86 because AnyCPU is invalid (explicit x86 prevents the binary from being loaded in a 64-bit processes, AnyCPU+Prefer32Bit does not) but where you may still want LAA.