简体   繁体   中英

LargeAddressAware Visual Studio 2015 C#

So today I decided I would update to Visual Studio 2015 (previously running the RC version with no difficulties) but now my project does not like the largeaddressaware command line event.

I have a post-build event of:

call "$(DevEnvDir)..\tools\vsvars32.bat"
editbin /largeaddressaware "$(TargetPath)"

However I get the following error:

The command "call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE..\\tools\\vsvars32.bat" editbin /largeaddressaware "C:\\...\\bin\\Debug\\Application.exe"" exited with code 9009

Any thoughts?

I call a cmd script as a PostBuildEvent:

IF  EXIST  "%VS140COMNTOOLS%"  CALL  "%VS140COMNTOOLS%vsvars32.bat"
IF  EXIST  "%VS120COMNTOOLS%"  CALL  "%VS120COMNTOOLS%vsvars32.bat"
IF  EXIST  "%VS110COMNTOOLS%"  CALL  "%VS110COMNTOOLS%vsvars32.bat"
IF  EXIST  "%VS100COMNTOOLS%"  CALL  "%VS100COMNTOOLS%vsvars32.bat"

editbin.exe /LARGEADDRESSAWARE MyApp.exe

It checks for the environment variable according to the installed VS (first 2015, next 2013, next 2012 and finally 2010) and now all paths are fine.

If it still can't find the .exe, make sure the C++ Tools option in the installer is selected. By default VS2015 only installs C# and VB.net, but not C++ with its tools. Here you have to activate it under custom in the setup:

在此输入图像描述

If you set your platform to "Any CPU" this flag is set for you by default now in Visual Studio 2015.

See Compiling C# with Any CPU sets Application can handle large (>2GB) addresses .

The issue was caused when uninstalling the Visual Studio 2015 RC version. It does not remove all the directories and therefore the install of the full release version is not successful. The simple solution is to uninstall the RC version and restart. Then manually delete the C:\\Program Files (x86)\\Microsoft Visual Studio 14.0 directory. Then you can install the the new version without any issues.

Credit Hans Passant for identifying this issue.

My problem with this, that I was calling vcvarsall.bat from the wrong location first. I'd upgraded to Visual Studio 2017, and vcvarsall.bat had moved. (So had EditBin.exe . There are 4 locations for it now, though I changed to using whatever was in the path.) Fixing that, fixed the problem. Here's my post-build file for your purview.

:: Install C++ tools to have these installed

:: build for 32 bit     
:: VS 2012 call "$(DevEnvDir)..\..\vc\vcvarsall.bat" x86 

:: build for 64
:: VS 2012 call "$(DevEnvDir)..\..\vc\vcvarsall.bat" amd64
:: VS 2017
call "$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvarsall.bat" amd64

:: "$(DevEnvDir)..\..\vc\bin\EditBin.exe" "$(TargetPath)"  /LARGEADDRESSAWARE
EditBin "$(TargetPath)"  /LARGEADDRESSAWARE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM