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

后端 未结 4 1912
自闭症患者
自闭症患者 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:36

    Create a helper class that wraps both 64bit and 32bit DLLS, and use IntPtr.Size to determine which to call.

    if (IntPtr.Size == 8)
    {
        Helper.SomeMethod64();
    }
    else
    {
        Helper.SomeMethod32();
    }
    

提交回复
热议问题