简体   繁体   中英

How to Force an assembly to run as x64 bit which was built against AnyCPU platform?

I've an assembly which is built against "AnyCPU" platform on .NET 4.5.2 But when i run the assembly on a 64 bit machine the dll is taking 32 bit form, After researching a lot i came to know about this thing that in .NET 4.5 and above "ANYCPU with 32BITPREF" is the defualt. we can use corflags tools and set the flag to 32bitpref-, so that dll will take 64 bit.

But my problem is that is has to happen from build script only so that no need to manually change it later.

Like we specify for platform and release mode or debug mode

Is there any property for 32bitpref- , such that it can set/reset from build script only??

Thanks in advance for the help.

Regards Prem

Quite a lot of properties have reasonable names in msbuild to set them. Here this is the case too, property is named Prefer32Bit, and so can be set in csproj file:

<Prefer32Bit>false</Prefer32Bit>

As with all properties, it can be set from msbuild command line with /property:[PropertyName]=[PropertyValue] syntax (or in short form: /p:[PropertName]=[PropertyValue]).

msbuild ... /property:Prefer32Bit=false

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