Dot-Net

Visual Studio 載入正確的(x86 或 x64)dll

  • May 4, 2010

我正在使用 x86 中的 Visual Studio。我想為 x32 和 x64 建構我的應用程序。但我需要使用 sqlite .net 連接器,它有一個用於 x86 應用程序的 dll 和另一個用於 x64 應用程序的 dll。

如何配置我的 Visual Studio 以在我的配置為 x64 時載入引用,而在我的配置為 x86 時載入另一個引用?

在您的項目文件中參考使用 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>

引用自:https://stackoverflow.com/questions/2762178