简体   繁体   中英

Referencing x86 and x64 DLL in C++/CLI wrapper based on project configuration?

I do still have an outstanding question that I am not sure of the answer.

When I followed the tutorials to create a C++/CLI wrapper for my DLL I had to add a reference to the DLL to the project:

参考

No problem with that, as such. But here is the thing, the reference path is:

D:\\My Programs\\2017\\MSAToolsLibrary\\MSAToolsLibrary\\bin\\x86\\Release\\MSAToolsLibrary.dll

I actually have two DLL files. One for x86 and one for x64. Can I set up the wrapper project files in such a way that it references the x64 file and x86 file respectively based on the build configuration?

Update

This is my VCXPROJ file:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 [snip]
  <ItemGroup>
    <Reference Include="MSAToolsLibrary">
      <HintPath>..\..\MSAToolsLibrary\MSAToolsLibrary\bin\x86\Release\MSAToolsLibrary.dll</HintPath>
    </Reference>
 [snip]
</Project>

I can see a reference to the DLL but I can't see a specific reference for x64 and x86 respectively.

Update 2

OK, I added the wrapper project into I real solution. x64 is building OK:

x64 1

x64 2

But when I set the configuration to x86 I have some problems. There is a small triangle on the references and the errors in the properties:

x86 1

x86 2

As you will see from my comment on the existing answer, I am using $(PlatformTarget) in the hint. But it seems there is somewhere else we need to adjust references that I can't work out.

Update 3

OK, If I open the project on it's own in Visual Studio then I can toggle the platforms fine. But when the project is part of my larger project, it does not like it. That is when it fails.

Update 4

Interestingly, if I am in my master project, and set to the x86 platform, and then in this added project I remove the reference to the DLL and go to add it again (the x86 flavour):

添加参考

I do not have this problem in the local solution. It seems like I have to do my development in the local solution and compile there, outside of my master project solution. :(

编辑<HintPath>

  <HintPath>..\..\MSAToolsLibrary\MSAToolsLibrary\bin\$(Platform)\$(Configuration)\MSAToolsLibrary.dll</HintPath>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM