How to use the correct unmanaged DLL file according CPU architecture? (32 / 64 bits)

后端 未结 3 1662
滥情空心
滥情空心 2020-12-17 01:01

I have to use a C++ DLL file from an ASP.NET site. The site will be hosted on both 32 and 64 bits environments.

I have a 32 and 64 bits version of the unmanaged DLL

3条回答
  •  悲哀的现实
    2020-12-17 01:15

    As we know that we cannot add unmanaged DLL files using add reference. So we need an alternative way to handle unmanaged DLLS files according to CPU architecture that is add DLL files in your project directories.

    1. Create new folders into your project named x32 and x64.
    2. Copy your DLL files into these folders according to architecture.
    3. Select the files and open properties, Change "Copy to output directory: Copy always"
    4. Repeat this on all files in both folders

    Now build your project in any platform when you will build the project both x86 and x64 folder will be copyed in bin folder. When this will run on server it will use unmanaged DLL files according to CPU architecture.

提交回复
热议问题