I have a project which configured for "Any CPU". Now I have to refer a third party dll which has x86 and x64 compiled versions seperately(I cant get AnyCPU version of third party dll). I have changed the configuration file of my project to refer particular dll based on the platform as shown below.(This is a sample project config file)
<PropertyGroup>
<CurrentPlatform>x86</CurrentPlatform>
<CurrentPlatform Condition="'$(PROCESSOR_ARCHITECTURE)'=='AMD64' or '$(PROCESSOR_ARCHITEW6432)'=='AMD64'">x64</CurrentPlatform>
</PropertyGroup>
<ItemGroup Condition=" '$(Platform)' == 'x86' ">
<!--Compiled as ClassLibrary target platform is x86-->
<Reference Include="ClassLibrary">
<HintPath>..\..\ClassLibrary_x86\ClassLibrary_x86\bin\Debug\ClassLibrary.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'x64' ">
<!--Compiled as ClassLibrary target platform is x64-->
<Reference Include="ClassLibrary">
<HintPath>..\..\ClassLibrary_x64\ClassLibrary_x64\bin\Debug\ClassLibrary.dll</HintPath>
</Reference>
</ItemGroup>
when I run this project in Visual studio it is not working. throwing BadImageException. When I change My project target platform to x86 and run the application it will work. If I change it to x64 then throw the same BadImageException.
What is the wrong here? I don't want to create two projects(x86 and x64) just because of one dll reference. Is there any other way to proceed if the above way is wrong?
My Dev environment is VS2010 and .NET4.0 and Win7 64bit OS.