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

Elena Aralla elena.aralla at gmail.com
Mon Jul 23 09:08:33 PDT 2018


Hello,

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
    {
        [CustomAction]
        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;

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

                //    session.Log(ex.Message);
                //    return ActionResult.Failure;
                //}
                //finally
                //{
                //    reader.Close();
                //    reader.Dispose();
                //    comm.Dispose();
                //    conn.Close();
                //    conn.Dispose();
                //}
            }
            else
            {
                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;
            }
            else
            {
                return ActionResult.Failure;
            }
        }
    }
}

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



More information about the wix-users mailing list