Building messaging applications with “Any CPU”


 

When building pure .NET applications doing builds using Any CPU usually go pretty smoothly. Even when mixing in some COM objects things usually go well. However, developers often run into issues with .NET code using COM objects then deploying their applications to other computers where the bitness of their development box OS does not match that of where they are deploying their application.

Keep in mind that the bitness of modules/DLLs being loaded into an application’s process must match the bitness of that process. That is you only should load a 32bit DLL into a 32bit process (application) and only load a 64 bit DLL into a 64 bit application.

When Any CPU is used:

The bitness build settings are set in the Solutions Configurations pull down in the main window in Visual Studio – where it notes a Debug or Release build.

64-bit Applications               
http://msdn.microsoft.com/en-us/library/ms241064(v=vs.110).aspx

In Windows this is how code runs based-upon the bitness platforms tags set at the time the code was compiled:

    Platform     Windows     Windows
    Bitness      32bit      64bit
    ————+————+——-
    Any CPU      32bit       64bit
    32bit        32bit       32bit
    64bit        Fails       64bit

Code built under “Any” will run at the highest bitness level that the OS supports.  So, for 64 Bit windows an application compiled as “Any” will be run as 64bit.  It would also run as 32bit on an 32bit OS.  However, code which is set to a specific bitness will only run under the bitness architecture set at compile time.

MAPI:

Please refer to this article:

Building MAPI Applications on 32-Bit and 64-Bit Platforms
https://msdn.microsoft.com/en-us/library/office/dd941355.aspx

Different bitness levels means different builds:

If your organization developed 32-bit MAPI applications, add-ins, or macros for Outlook, there are actions that you should take to change and rebuild the 32-bit applications to run on a 64-bit platform. For information about how to prepare Outlook applications for 32-bit and 64-bit platforms, see the Outlook 2013 MAPI Reference in Microsoft Office Development in the MSDN Library.

CDOSYS:

Please refer to this article – it covers bitness with CDOSYS:

HowTo: Set a reference to CDOSYS
https://blogs.msdn.microsoft.com/webdav_101/2016/06/28/howto-set-a-reference-to-cdosys/


Outlook product:

Here are some highlights to be aware of:

  • Be aware of issues with different versions of Outlook and mixing versions or bitness.
  • You can mix some MSI installed versions of outlook with Click-to-Run installs. Two MSI installs of Outlook are not supported.
  • When you upgrade Office it must be of the same bitness. This goes for Outlook as well as its part of Office.
  • The bitness of the DLLs you load into Outlook MUST match the bitness of Outlook.

Please review:

64-bit editions of Office 2013
https://technet.microsoft.com/en-us/library/ee681792(v=office.15).aspx

64-bit editions of Office 2010
https://technet.microsoft.com/en-us/library/ee681792(office.14).aspx

Outlook Development:

One of the development challenges with doing targeted releases for code involving Outlook is determining what the bitness is of Outlook.

Bitness : How to identify Outlook 2010 installation is a 32-bit or 64-bit?
https://blogs.msdn.microsoft.com/deva/2010/01/21/bitness-how-to-identify-outlook-2010-installation-is-a-32-bit-or-64-bit/

Example: Outlook 14.0 32bit under 64bit Windows 10 the bitness flag is x86 here:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Office\14.0\Outlook

Example: Outlook 14.0 32bit under 64bit Windows 10 the bitness flag is x86 here:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Office\16.0\Outlook

How to: Check the Version of Outlook
https://msdn.microsoft.com/en-us/library/office/dd941331.aspx

How to: Determine Whether Outlook Is a Click-to-Run Application on a Computer
https://msdn.microsoft.com/en-us/library/office/ff522355.aspx

You should to target your builds if your using unmanaged code in something (an add-in) running in Outlook unless you know the bitness of the OS will match that of Outlook and that the bitness of the components used by your application also match.

Developing Outlook 2010 Solutions for 32-Bit and 64-Bit Systems
https://msdn.microsoft.com/en-us/library/office/gg549122(v=office.14).aspx

Sample – Detect bitness of the current process and the bitness of Windows:

if (Environment.Is64BitOperatingSystem)
Console.WriteLine(“OS Bitness is 64 bit”);
else
Console.WriteLine(“OS Bitness is 32 bit”);

if (Environment.Is64BitProcess)
Console.WriteLine(“This Application’s process Bitness is 64 bit”);
else
Console.WriteLine(“This Application’s process Bitness is 32 bit”);

 

Further Information:

AnyCPU Exes are usually more trouble than they’re worth
https://blogs.msdn.microsoft.com/rmbyers/2009/06/09/anycpu-exes-are-usually-more-trouble-than-theyre-worth



How to: Determine Which .NET Framework Versions Are Installed
https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx

 


Comments (0)