Sunday, May 30, 2010

How to detect if the x64 SQL Compact 3.5 SP2 desktop runtime is installed

For x64 system with SQL Compact, it is required that both the x86 and x64 runtimes are installed, see this KB for more info.

So how can your installer detect if any of these versions are installed: by looking in the registry.

 

x64 system with only x86 runtime installed:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU]
    "DesktopRuntimeVersion"="3.5.8080.0"
    "DesktopRuntimeServicePackLevel"="2"

 

x64 system with both x86 and x64 installed:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU]
    "DesktopRuntimeVersion"="3.5.8080.0"
    "DesktopRuntimeServicePackLevel"="2"
    "DesktopRuntimeVersion_x64"="3.5.8080.0"

and

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU]
"DesktopRuntimeVersion"="3.5.8080.0"
"DesktopRuntimeServicePackLevel"="2"

 

x64 system with only x64 runtime installed:

This is not possible with SQL Compact 3.5 SP2, attempting this will result in the following blocking error:

x64sqlce

 

Detection

So depending on the target platform (“x86”, “x64” or “AnyCPU”) of your installer, you can detect as follows:

- x86 based installer: 

Both these keys must be present and have proper values in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU

(x86 platform reads the Wow6432Node as if it was the “normal” HKLM\Software node).

    "DesktopRuntimeVersion"="3.5.8080.0"  (x86 runtime installed)
    "DesktopRuntimeVersion_x64"="3.5.8080.0" (x64 runtime installed)

- x64 and AnyCPU based installer:

If the key below is present and have proper values, all is well:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU]
"DesktopRuntimeVersion"="3.5.8080.0" (x64 and x86 runtimes installed)

If not, you must check the key below in HKEY_LOCAL_MACHINE\Wow6432Node\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU

(to avoid reinstalling the x86 runtime);

    "DesktopRuntimeVersion"="3.5.8080.0" (x86 runtime installed) 

4 comments:

A said...

Hi Erik,

I check to see if it's installed by checking for the installed product codes of:
{D4AD39AD-091E-4D33-BB2B-59F6FCB8ADC3} for the 64 bit version and {3A9FC03D-C685-4831-94CF-4EDFD3749497} for the 32 bit version using MsiQueryProductState (extracted from Orca).

Does that sound like a reasonable strategy or do I have to change to looking at registry keys?

ErikEJ said...

Sounds doable, but the product IDs could change.

A said...

Yes, that's true.

My code checks for those specific product ID's then downloads the SP2 installers from my website though if they're not there, so I guess the only issue is what happens when SP3 comes along and my code tries to install SP2.

I probably have a similar problem with SP1 at the moment.

A said...

Hmm. Yes, the existing installer sees SP1 is no longer installed, and then downloads it, only to find that it's already installed when run.

I guess I need a new strategy. :(