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

时间:2010-05-04 01:04:03

标签: .net visual-studio 64-bit system.data.sqlite

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

谢谢, 理查德。

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分: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>

答案 2 :(得分:0)

您还可以为“任何CPU”构建应用程序,并动态选择要加载的DLL。