Renat Tlebaldziyeu

Outlook Security Manager deployment: compiling a standalone application with “AnyCPU”, part 4

This is the 4th part of the Outlook Security Manager 2010 deployment series, in which we will look at the deployment of standalone applications compiled with AnyCPU on 32-bit and 64-bit machines. But first off, I advise that you read through Part 1: Outlook Security Manager 2010 deployment:.net, ActiveX and VCL basics

As stated in the Deployment chapter of the Outlook Security Manager Developer Guide: “In terms of Visual Studio, you must never use AnyCPU as the platform for which you build your application; the platform must be x86 for Outlook 2000-2007 and Outlook 2010 32-bit and x64 for Outlook 2010 64-bit.”

But this does not mean that you don’t have a possibility to get your standalone application compiled with the “AnyCPU” option to work as a 32-bit application on a 64-bit PC. That is, you can still deploy a single version of your standalone application on x86 and x64 machines.

So, if you deploy a standalone application (not an Outlook add-in!), make sure the bitness of your application is the same as that of Outlook, not the bitness of the operating system. That is, your application must be 32-bit if used for Outlook 2000-2007 and Outlook 2010 32-bit; it must be 64-bit if used for Outlook 2010 64-bit.

If your standalone application is compiled with “AnyCPU” and you want it to work with a 32-bit Outlook version on a 64-bit operating system, you need to configure the CorFlags section of the header of your portable executable image and sets the 32BIT flag.

In order to do this, you will need the “CorFlags Conversion Tool” (CorFlags.exe). You can find it in the {SDK}\v2.0\Bin directory on MSDN.

Deployment for Outlook 32-bit and x64 Windows

If you are going to deploy your standalone application on the target PC with Outlook 32-bit and x64 Windows installed:

1. Include CorFlags.exe in your installation package.

2. Using CorFlags.exe, configure the CorFlags section of the header of your portable executable image and set the 32BIT flag:

CorFlags.exe "{path to your executable file}" /32BIT+

To do this, you can use, for example, Custom Actions in your setup package.

How to use Custom Actions for configuring the CorFlags section:

1. First of all, make sure that your setup package includes CorFlags.exe.

2. Create two launch conditions of the Registry Search type as described in step 3 of Part 3: Outlook Security Manager 2010 deployment: self-registration in a Visual Studio setup project. They will enable you to determine if you need to set the 32BIT flag, as you remember it should be set only if your standalone application is supposed to work with a 32-bit Outlook version on a 64-bit operating system.

3. Set the Exclude property for the CorFlags.exe file to True. When this property is set to True, the  CorFlags.exe is not extracted to the target application folder, but notwithstanding this, the Custom action, described further at step 5. will be executed.

4. Set the Condition property for the CorFlags.exe file to (Msix64) and ((OLVER <> “Outlook.Application.14″) or ((OLVER=”Outlook.Application.14”) and (OLBIT = “x86”))).

Setting the Condition property for the CorFlags.exe file

In this Condition, we use the Msix64 Property and condition that are already familiar to you from Part 3. The Msix64 Property is defined only if your setup package runs on an x64 processor. Note that the Msix64 property is available beginning with Windows Installer 3.1.

5. Go to the Custom Actions editor and add a new Custom Action for CorFlags.exe.

6. Set the Arguments property for the newly created Custom Action to “[TARGETDIR]SimpleApp.exe” /32BIT+ , where SimpleApp.exe is the name of your executable file.

7. Set the Condition property for the new Custom Action to (Msix64) and ((OLVER <> “Outlook.Application.14″) or ((OLVER=”Outlook.Application.14”) and (OLBIT = “x86”))). This condition is required for the Custom Action not to be run on a 64-bit PC with Outlook 2010 64-bit and on a 32-bit PC with other Outlook versions.

Setting the Condition property for the custom Action

Well then, the steps above will make your standalone application work as a 32-bit application on the target 64-bit PC with Outlook 32-bit.

That's all, hope this will help you deploy your software that uses our Outlook Security Manager without a hitch.

You may also be interested in:

Outlook Security Manager deployment:.net, ActiveX and VCL basics, part 1
Outlook Security Manager deployment: bitness and regsvr32 utility, part 2
Outlook Security Manager deployment: self-registration in a Visual Studio setup project, part 3

7 Comments

  • ruslan vesylivskyy says:

    Hi,

    I recieve “#389 General failure building custom actions” error when try to build my setup project.

    Could you please describe this step more detail ? Should it be a custom action for Install/Commit/.. ?

    -Ruslan

    P.S I have changed the double quotation marks to singles in “Condition” field

  • Sergey Grischenko (a member of the Add-in Express team) says:

    Hi Ruslan,

    The error was caused by changing the double quotation marks to singles. Please adhere to correct formatting supported by the setup project, as recommended in the article. This article describes the use of the Install custom action.

  • ruslan vesylivskyy says:

    Hi Sergey,

    After your suggestion I can make new installers. Thanks!

    But still I need some clarifications about step 7 :

    For custom actions we have (Install, Commit, RollBack, Uninstall) . Do I need set arguments as “[TARGETDIR]SimpleApp.exe” /32BIT+ for all these installation steps ?

    -Ruslan

  • Renat Tlebaldziyeu (Add-in Express Team) says:

    Hi Ruslan,

    Good news! Thank you for letting us know.
    You should add a new CorFlags.exe custom action only for the Install group. You don’t need to configure the CorFlags section of the header of your portable executable image and set the 32BIT flag when you uninstall your application or initiate the rollback process.

  • Stefan Walther says:

    Hi,

    do you have a WiX-example for the CoreFlags.exe example mentioned above?

    Thank you very much in advance!

    Regards
    Stefan

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Stefan,

    Please see the WiX example below:

    <!– The ‘Search for Outlook version’ Registry Search. –>
    <Property Id=’OLVER’>
    <RegistrySearch Id=’_3D6D8A38_04A2_4367_8419_55D93EBC29D9′ Root=’HKCR’ Key=’Outlook.Application\CurVer’ Type=’raw’ />
    </Property>
    <!– The ‘Search for Bitness in Outlook 2010′ Registry Search. –>
    <Property Id=’OLBIT’>
    <RegistrySearch Id=’_45D86C71_499F_499B_A232_577D49FBB903′ Root=’HKLM’ Key=’SOFTWARE\Mictosoft\Office\14.0.\Outlook’ Name=’Bitness’ Type=’raw’ />
    </Property>

    <!– The ‘CorFlags.exe’ custom action. –>
    <CustomAction Id=’_5EC807CE_3B37_4865_8BB5_0AA78F622FCF’ BinaryKey=’_0E2DC90F_D1FF_0E4A_9303_49F9B273A337′ Execute=’deferred’ ExeCommand='”[TARGETDIR]MyApplication.exe” /32BIT+’ />
    <Binary Id=’_0E2DC90F_D1FF_0E4A_9303_49F9B273A337′ SourceFile=’C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\CorFlags.exe’ />

    <InstallExecuteSequence>

    <Custom Action=’_5EC807CE_3B37_4865_8BB5_0AA78F622FCF’ After=’StartServices’><![CDATA[((Msix64) and ((OLVER <> “Outlook.Application.14″) or ((OLVER=”Outlook.Application.14”) and (OLBIT = “x86″)))) AND NOT REMOVE~=”ALL”]]></Custom>
    </InstallExecuteSequence>

  • Stefan Walther says:

    Thank you very much!!!

    Regards
    Stefan

Post a comment

Have any questions? Ask us right now!