C#: Access 32-bit/64-bit DLL depending on platform

后端 未结 4 1909
自闭症患者
自闭症患者 2021-02-09 23:48

we use a self-written 32bit C++ DLL from our C# applications. Now we\'ve noticed that when the C# applications are run on a 64bit system, the 64bit runtime is automatically used

4条回答
  •  情话喂你
    2021-02-10 00:14

    I had similar problem but it was with Unrar.dll being either 32 or 64bit.

    There can be two approaches to make it work:

    a)

    #if x64
    // ... define all x64 imports here
    #else
    // ... define all x86 imports here
    #endif
    

    And compile application for 32Bit and 64bit.

    b) Another way was to create an interface for the imports and implement 32 bit and 64 bits versions separately.

    If 32 bit, instantiate the 32 bit implementation, else instantiate the 64 bit implementation.

提交回复
热议问题