locked
How can I make my .winmd references per configuration in a VS2012 C++ / CX project?

    Question

  • If I add a reference to a .winmd in my WinRT C++ / CX VS 2012 project, I get this in the .vcxproj file:

      <ItemGroup>
        <Reference Include="Leadtools">
          <HintPath>..\Leadtools\Win32Debug18\Leadtools.winmd</HintPath>
          <IsWinMDFile>true</IsWinMDFile>
        </Reference>
      </ItemGroup>
    

    But, notice that it is not dependent on the configuration.  So, if I try to build x64, then it will fail with an error:

     

    error MSB3271: There was a mismatch between the processor architecture of the project being built "ARM" and the processor architecture, "x86", of the implementation file "xxxx\Win32Debug18\xxx.dll" for "xxxx\Win32Debug18\xxx.winmd". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and implementation file, or choose a winmd file with an implementation file that has a processor architecture which matches the targeted processor architecture of your project.

    Is there a way to add the reference in code and wrap using an #ifdef or is there some other solution?  I do not want to have to have separate projects for each platform (ARM, Win32, x64).

    Thursday, August 9, 2012 6:47 PM

Answers

  • I think I have found a workable solution.  I changed the HintPath to use the Visual Studio property $(Platform):

          <HintPath>..\..\Dist\Bin18\WinRT\$(Platform)\Debug\Leadtools.winmd</HintPath>

    • Marked as answer by BullyOwner Friday, August 10, 2012 3:01 AM
    Friday, August 10, 2012 3:00 AM

All replies

  • I think I have found a workable solution.  I changed the HintPath to use the Visual Studio property $(Platform):

          <HintPath>..\..\Dist\Bin18\WinRT\$(Platform)\Debug\Leadtools.winmd</HintPath>

    • Marked as answer by BullyOwner Friday, August 10, 2012 3:01 AM
    Friday, August 10, 2012 3:00 AM
  • Thanks for sharing the solution.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, August 13, 2012 9:07 AM