[wix-users] ERROR in custom action using sql CE

Hoover, Jacob Jacob.Hoover at greenheck.com
Mon Jul 23 09:21:14 PDT 2018

Even if you could get it working on your development machine, there is no guarantee that the end users machine would have this. (If your using burn, then if CE is in the chain before this MSI, it should be...) Users and other installers can do some crazy things, so you need to be sure that the CA is only ran on install, or that it can respond to CE missing.

That being said, I've only ever used the native CE components.  You need to remember your CA DLL does not get installed (it's extracted to temp and ran from a random file name).  As such, if you have dependencies on CE and CE isn't in the GAC or registered on the system (COM), then you would need to include a copy of CE in the MSI to be extracted to the temp folder prior to running your CA.

Ref: https://stackoverflow.com/questions/1591700/how-to-execute-a-wix-custom-action-dll-file-with-dependencies

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Elena Aralla via wix-users
Sent: Monday, July 23, 2018 11:09 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Elena Aralla <elena.aralla at gmail.com>
Subject: [wix-users] ERROR in custom action using sql CE


I'm trying to write a custom action that connects to a sql server compact edition database to execute a simple query:

In the MSI logs, I find this internal exception:


MSI (s) (9C!4C) [17:42:10:426]: Creating MSIHANDLE (120) of type 790531 for thread 15436
System.Reflection.TargetInvocationException: Eccezione generata dalla destinazione di una chiamata. ---> System.Data.SqlServerCe.SqlCeException: Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8482. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.
   in System.Data.SqlServerCe.NativeMethods.LoadNativeBinaries()
   in System.Data.SqlServerCe.SqlCeConnection..ctor()
   in System.Data.SqlServerCe.SqlCeConnection..ctor(String connectionString)
   in DB.CustomActions.GetSysyConfig(Session session) in W:\codice\WIX_SETUP\CustomActions\DB\CustomAction.cs:riga 29
   --- Fine della traccia dello stack dell'eccezione interna ---


I'm sure that SQL Server Compact Edition is installed on my development machine; in the custom action I added the reference to the installed SQL Server Compact Edition library.

This is My Custom action Code; the error is on the line SqlCeConnection conn = new SqlCeConnection(ConnString);

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.Data.SqlServerCe;

namespace DB
    public class CustomActions
        public static ActionResult GetSysyConfig(Session session)
            session.Log("Begin GetSysyConfig");
            String cfgcode = session["CFGCODE"];
            String cfgvalue = "test";

            session.Log(String.Format("Config value code = {0}", cfgcode));

            String dbFile = @"W:\database\empty_pec.sdf";

            if (System.IO.File.Exists(dbFile))
                String ConnString = String.Format(@"Data Source ={0}; File Mode = Read Write; Max Database Size = 1024; Persist Security Info = False", dbFile);

                session.Log(String.Format("ConnString = {0}", ConnString));

                SqlCeConnection conn = new SqlCeConnection(ConnString);

                //String query = String.Format(@"select cfg_value 
                //                    from sys_configs 
                //                    where cfg_cvode = {0}", cfgcode);
                //SqlCeCommand comm = new SqlCeCommand(query, conn);
                //SqlCeDataReader reader = null;

                //    conn.Open();
                //    reader = comm.ExecuteReader();
                //    if (reader.Read())
                //    {
                //        cfgvalue = reader.GetValue(0).ToString();
                //    }
                //catch (Exception ex)

                //    session.Log(ex.Message);
                //    return ActionResult.Failure;
                //    reader.Close();
                //    reader.Dispose();
                //    comm.Dispose();
                //    conn.Close();
                //    conn.Dispose();
                session.Log(String.Format("File {0} does not exist", dbFile));

            session.Log(String.Format("Config value = {0}", cfgvalue));
            session.Log("End GetSysyConfig");

            if (!String.IsNullOrEmpty(cfgvalue))
                return ActionResult.Success;
                return ActionResult.Failure;

Does anyone have any idea what I'm doing wrong? thank you.

WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

More information about the wix-users mailing list