C# Directive to indicate 32-bit or 64-bit build

后端 未结 9 1514
你的背包
你的背包 2020-12-16 04:04

Is there some sort of C# directive to use when using a development machine (32-bit or 64-bit) that says something to the effect of:

if (32-bit Vista)
    // set a         


        
9条回答
  •  旧时难觅i
    2020-12-16 05:04

    I know that this is an old topic, but I recently had to achieve the same result (i.e. determine at build time, not run time)

    I created new build configurations (x86 debug, x86 release, x64 debug, x64 release) and set BUILD64 or BUILD32 in the "Conditional compilation symbols" box in the application properties for each configuration.

    When I needed to do something different between builds (like change the signature on some x86 exported methods from a .dll), I then used standard build directives to achieve what I needed. for instance:

    #if BUILD64
    // 64 Bit version
    // do stuff here
    #endif
    
    #if BUILD32
    // 32 Bit version
    // do different stuff here
    #endif
    

提交回复
热议问题