Setting dllimport programmatically in C#

后端 未结 9 1964
情话喂你
情话喂你 2020-12-30 11:10

I am using DllImport in my solution.
My problem is that I have two versions of the same DLL one built for 32 bit and another for 64 bit.

They both e

9条回答
  •  死守一世寂寞
    2020-12-30 11:22

    Hmm, I'm wondering if you could create an interface and then a class with the methods based on the 32 bit and 64 bit dlls.

    I'm not sure if there is an explicit method to determine if you are running 64 bit, but the following might work: allow unsafe code and have an unsafe function that gets a pointer to some address and then determine whether the pointer is 4 or 8 bytes in size. Based on the result determine which implementation of the interface to create.

提交回复
热议问题