How to add a link to the class library if I need both 32-bit and 64-bit

In my project, I use both configurations - 32-bit and 64-bit (because I am developing on a 32-bit machine, but deploy it on a 64-bit machine).

My project contains a class library located in the folder "C: ... \ Commons \ bin \ Debug \ Commons.dll". I added this DLL to the links, but of course, when I switched to 64-bit, this will not work.

So, I need a mechanism to add โ€œplatform linksโ€.

I know I can edit the .csproj file to add something like this:

<Reference Include="Commons" Condition="$(Platform) == 'x64'"> <HintPath>..\Commons\bin\x64\Release\Commons.dll</HintPath> </Reference> <Reference Include="Commons" Condition="$(Platform) == 'x86'"> <HintPath>..\Commons\bin\x86\Release\Commons.dll</HintPath> </Reference> 

Should I do the same for the class library?

I'm just curious that VS does not support the platform-dependent reference mechanism even for class libraries?

upd It seems that I really need to bind 4 types of dll somehow - x86 / Debug, x86 / Release, x64 / Debug, x64 / Release

+4
source share
2 answers

You really shouldn't. You must compile your code in MSIL and add links to the MSIL DLL versions. Your code and reference code will be compiled at runtime at runtime. If it runs on an x86 computer, it will be compiled on x86, and on an x64 computer it will be compiled to x64. You do not need to worry about it.

If you think JIT is slow and you need performance, you can configure your builds on target computers.

+1
source

The next question has a solution to your problem. Hope this helps. Conditionally use 32/64 bit links when creating in Visual Studio

0
source

Source: https://habr.com/ru/post/1415093/


All Articles