Archived Forum Post

Index of archived forum posts

Question:

Chilkat "Any CPU" with .NET 4.5 C# and VB.NET Projects

Apr 18 '14 at 11:51

I am somewhat confused by the behavior of the ChilkatDotNet45 dlls.

According to your documentation and my own understanding of how "Any CPU" works, I should reference the 64 bit DLL when compiling on a 64 bit OS and using the "Any CPU" configuration. In reality, I must use the 32 bit DLL under these conditions. This confusion is causing problems throughout our development team. I appreciate your attention to this problem.


Answer

The Chilkat .NET assembly is a mixed-mode DLL, meaning that internally it contains native code (because it is written in C++, which allows the same internal implementation to be used across many different programming languages and operating systems). Note: The Chilkat .NET assembly does not use COM in any way.

Given that it's a mixed-mode DLL (with a managed API, but native internals), the DLL used at application runtime must match the address space of the process. Obviously, if running on a 32-bit platform, there is only one possible choice: 32-bit.

If running on 64-bit Windows, your app might be running as a 32-bit or 64-bit process. In Visual Studio 2012, look at your C# or VB.NET project's properties. Look at the Build properties. You'll see a checkbox for "Prefer 32-bit". If checked, and the Platform Target is "Any CPU", then your app will always run as a 32-bit process, even on 64-bit Windows. In this case, you would always use the 32-bit Chilkat assembly.

If the "Prefer 32-bit" checkbox is unchecked, then your app will run as a 32-bit process on 32-bit Windows, and as a 64-bit process on 64-bit Windows. In that case, you would need to use the 64-bit Chilkat assembly at runtime on 64-bit Windows, and (of course) the 32-bit Chilkat assembly on 32-bit Windows.