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

2k views Asked by At

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

1

There are 1 answers

0
Evk On

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