x86
and x64
, then it can bring us a certain headache. We will proceed from the fact that limiting our application, for example, only to the 32-bit process is not in our rules.x86
version, and ReSharper can run tests in the 64-bit process. In addition, you will have to release two distributions and provide the user with oh when downloading from the site what a difficult choice. Therefore, a reasonable solution seems to be the choice of a library that is suitable for operation already at runtime, depending on which process (32 or 64 bits) the code executes. At the same time, the projects themselves remain AnyCPU
.runtime/assemblyBinding
tag of the application configuration file. Add the following to app.config
: <configuration> <!-- ODP.NET Runtime --> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" culture="neutral" processorArchitecture="x86" /> <codeBase version="4.112.2.0" href=".\x86\Oracle.DataAccess.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" culture="neutral" processorArchitecture="amd64" /> <codeBase version="4.112.2.0" href=".\x64\Oracle.DataAccess.dll"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
processorArchitecture
attribute has four possible values: x86
, amd64
, msil
, ia64
. Paths in codeBase
may differ depending on the type of project (for example, for ASP.NET it should be href=".\bin\x64\Oracle.DataAccess.dll"
)..exe
applications) after the line <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildProjectDirectory)\..\CommonItems.targets" />
AfterBuild
project file. It must be uncommented / added / edited: <Target Name="AfterBuild" DependsOnTargets="CopyDataAccessFiles" >
CommonItems.targets
file contains the description of these common elements for executable projects. The goal for copying dependencies is defined here: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <OracleICFilesx86 Include="$(MSBuildProjectDirectory)\..\externals\OracleIC\x86\*.dll"> <Visible>False</Visible> </OracleICFilesx86> <OracleICFilesx64 Include="$(MSBuildProjectDirectory)\..\externals\OracleIC\x64\*.dll"> <Visible>False</Visible> </OracleICFilesx64> <OdpNetFilesx86 Include="$(MSBuildProjectDirectory)\..\externals\Odp.Net\x86\*.dll"> <Visible>False</Visible> </OdpNetFilesx86> <OdpNetFilesx64 Include="$(MSBuildProjectDirectory)\..\externals\Odp.Net\x64\*.dll"> <Visible>False</Visible> </OdpNetFilesx64> </ItemGroup> <Target Name="CopyDataAccessFiles" > <Copy SourceFiles="@(OracleICFilesX86);@(OdpNetFilesx86)" DestinationFolder="$(MSBuildProjectDirectory)\$(OutputPath)\x86\" SkipUnchangedFiles="true" UseHardLinkIfPossible="true" /> <Copy SourceFiles="@(OracleICFilesX64);@(OdpNetFilesx64)" DestinationFolder="$(MSBuildProjectDirectory)\$(OutputPath)\x64\" SkipUnchangedFiles="true" UseHardLinkIfPossible="true" /> </Target> </Project>
Source: https://habr.com/ru/post/165767/
All Articles