.NET, "Any CPU / 64Bit (x64) / 32Bit (x86)." The best recommendations, tips and tricks

If a .NET program directly or indirectly needs to call platform-dependent / native / un managed code, it may crash.

This 32-bit / 64-bit theme came to my mind after I got a new laptop with 64-bit version of Windows 7 installed and tried to develop a SQLite database.

System.Data.SQLite contains managed code plus unmanaged code. There is a 32-bit version and a 64-bit version, both have the same file name but different sizes, and your EXE should use the correct one.

To make it more complex: My Visual Studio 2010 Debugger is a 32-bit application , so I cannot debug when using "System.Data.SQLite-64bit", from the GAC !

As .NET developers, we need recommendations / know-how / best practices.

And the best place to collect such information that I know is this site ( /qaru.site / ... ).

Therefore, please share your ideas and known issues that may serve as best practices or recommendations to survive in the world of the 32/64 / anyCPU docking station.

I would prefer one problem / trick for the "answer" so it can be easily commented / updated / referenced. - Feel free to give a few "answers".

I also shared my knowledge with both the answer to this question.

+8
sample 32bit-64bit
source share
1 answer

Providing an additional "x86 only" main.exe can make life easier when native code is involved

After reading anycpu-exes-are-usually-more-trouble-then-they-re-worth, I realized that providing an extra "x86 only" main.exe could make life easier.

Since the 64-bit version of Windows 7 can run x86-32-bit applications, the x86 program will work on most .NET systems (but not on non-Intel Mono systems).

While the Visual Studio 2010 64-bit debugger for Windows 7 is a 32-bit application , the x86 application can be easily debugged.

In the x86 release, there are as many DLL files of any type as possible except the main EXE files and processor-specific libraries.

For machines that cannot run x86 code or where huge memory is required, you can provide an optional โ€œany processorโ€, EXE version. This version requires adequate installation to ensure that the correct code for the specific platform is used.

Visual Studio 2010 How to Set Up Projects for Target Platforms describes how to install the platform on x64. Similarly, you can configure x86.

+3
source share

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


All Articles