Visual Studio加载右侧(x86或x64)dll!

dam*_*oet 22 .net 64-bit system.data.sqlite visual-studio

我正在使用x86开发visual studio.我想为x32和x64构建我的应用程序.但我需要使用sqlite .net连接器,它有x86应用程序的dll和x64应用程序的另一个dll.当我的配置是x64时,如何配置我的visual studio加载引用?当我的配置是x86时,如何配置我的visual studio?

谢谢,理查德.

Pre*_*gha 21

在您的项目文件中使用MSBUILD条件

<Reference 
       Include="SomeAssembly86, Version=0.85.5.452, Culture=neutral, PublicKeyToken=41b332442f1101cc, processorArchitecture=MSIL"  
         Condition=" '$(Platform)' == 'AnyCPU' ">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\Dependencies\SomeAssembly.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference 
         Include="SomeOtherAssembly, Version=0.85.5.999, Culture=neutral, PublicKeyToken=41b332442f1101cc, processorArchitecture=MSIL" 
         Condition=" '$(Platform)' == 'x64' ">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\Dependencies\SomeOtherAssembly.dll</HintPath>
      <Private>False</Private>
    </Reference>
Run Code Online (Sandbox Code Playgroud)


Ron*_*Ron 10

这个比Preet Sangha更简单的答案在加载项目时不会生成警告,只有条件接受的dll才会出现在解决方案资源管理器中.所以,总的来说,外观更清晰,虽然更微妙.(这是在Visual Studio 2010中测试的.)

<Reference Include="p4dn" Condition="$(Platform) == 'x86'">
  <HintPath>..\..\ThirdParty\P4.Net\clr4\x86\p4dn.dll</HintPath>
</Reference>
<Reference Include="p4dn" Condition="$(Platform) == 'x64'">
  <HintPath>..\..\ThirdParty\P4.Net\clr4\x64\p4dn.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)