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) 

9 comments:

A Wieser 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 Wieser 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 Wieser 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. :(

Harry said...

Hi Erik,

We use the Advanced Installer default setting to detect the version number. It checks the registry data
"[HKLM]\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server Compact Edition\v3.5\Version" for the version number of SQL Server Compact 3.5 x86
"[HKLM]\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\Version" for the version number of SQL Server Compact 3.5 x64

However, many of our users have a problem. They have installed SQL Server Compact 3.5 SP2. It is listed in the Control Panel -> Programs and Features. But on some machines, the x86 registry value somehow keeps the SP1 version number 3.5.5692. On some machines, the x64 registry value keeps the SP1 version number.

This causes the installer try to install the SP2 again, but fails because the SP2 has been installed acutally.

Do you know why? Would this happen to the suggested registry value "DesktopRuntimeVersion" too?

ErikEJ said...

Harry: maybe they have a mixed install? Meaning x86 components are old, and the x64 bits are new?

Harry said...

Hi Erik

One of the users kindly sent us the screenshot of "Programs and Features". It shows only "Microsoft SQL Server Compact 3.5 SP2 ENU" and "Microsoft SQL Server Compact 3.5 SP2 x64 ENU" are installed. There is no other SQL Server installed.

On this user's computer, our installer finds the x86 version is the new one 3.5.8080, but the x64 version is the old one 3.5.5692 (based on the registry data above). So our installer tries to install the SP2 x64, but fails.

Most of the users have x86 version is the old one 3.5.5692, and the x64 version is the new one 3.5.8080. So our installer tries to install the SP2 x86, but fails.

We suggest them to uninstall all the Microsoft SQL Server Compact 3.5 and install again. This solves the problem. But since a lot of users have this problem and come to us for a solution, we need to find a way to solve this problem.

Regards
Harry

ErikEJ said...

Harry: Have you considered private deployment?

Harry said...

Thanks Erik. We'll consider private deployment again.

Harry