Preprocessor directive in C# for importing based on platform

前端 未结 4 1940
别跟我提以往
别跟我提以往 2020-11-28 12:03

Looking for a preprocessor directive in c# for importing dll based on whether the executable is 64bit or 32 bit:

#if WIN64
[DllImport(\"ZLIB64.dll\", Calling         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 12:20

    There is nothing builtin that I am aware of. However, it is simple to define a custom compilation constant. If you are using Visual Studio create different build configurations for 32bit and 64bit versions using the Configuration Manager. Then open the project properties and go to the Build tab and enter a descriptive name in the conditional compilation symbols textbox for each build configuration. Then you can reference the compilation constants in code.

提交回复
热议问题