On my development desktop, everything is fine. But when I installed the package on another VMs(Win7 and WinXP), it crashed. Then I checked the exception and figured out the reason is connecting DB error. I compared the environment between my development desktop and the VMs. The suspect is Microsoft SQL Server Compact 3.5 SP1 English. It means that I need the runtime of SSCE.
I have 2 choices to solve this problem. One is to install SSCERuntime-ENU-x86.msi during the installation, and the other is to put necessary drivers with AP.
- Install SSCE runtime during setup
In xxx.iss(Inno Setup Script) file, add belows:
[Files]
Source: SSCERuntime-ENU-x86.msi; DestDir: {tmp}; Flags: deleteafterinstall
Besides, we need to add some codes. First, check if SSCE installed.
RegKeyExists(HKLM, 'Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5');
If not installed, execute the SSCERuntime-ENU-x86.msi.
ExtractTemporaryFile('SSCERuntime-ENU-x86.msi');
Exec('msiexec',ExpandConstant('/i "{tmp}\SSCERuntime-ENU-x86.msi" /qb'),'', SW_SHOW, ewWaitUntilTerminated, ResultCode);
Actually, I preper this solution.
I read "LINQ and Deploying SQL Server CE 3.5" by Matt Sollars on CodeProject and tried so many times, but it didn't work. So if you guys read that article and everything is fine and you could jump this section.
Besides the 7 dlls that Matt Sollars suggested, I add "System.Data.SqlServerCe.Entity.dll".
In application config, check the version of System.Data.SqlServerCe
So, my App.config is:
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.3.5" />
<add name="Microsoft SQL Server Compact Data Provider"
invariant="System.Data.SqlServerCe.3.5"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory,
System.Data.SqlServerCe,
Version=3.5.1.0,
Culture=neutral,
PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>
</configuration>
Finally, don't forget to copy XXX.exe.config to the installation directory.