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

Elena Aralla elena.aralla at gmail.com
Wed Jul 25 02:49:21 PDT 2018


update:
the third point is not necessary!

Have a nice day, 
Elena.



> Il giorno 25 lug 2018, alle ore 10:20, Elena Aralla <elena.aralla at gmail.com> ha scritto:
> 
> 
> Hello,
> 
> in the end I found the way to:
> 
> 	"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"
> 
> 
> 1) I copied the folder that contains the sqlce dll in the folder where I saved the project of my Custom Action.
> 
> 2) I added the folder to my Custom Action project
> 
> 3) I set, for each file in the folder, the property:
> Copy to outut = always
> 
> WARNING: if the target platform is x86, do not add the dll of the amd64 folder, because they cause an exception during the execution of the custom action.
> 
> These operations cause the SQLCE DLLs to be added to the <myCustomAction> .CA.dll library used by WIX and extracted to the temporary folder when executing the custom action.
> 
> Thanks to Jacob for his email;
> thanks also to the authors of these two articles:
> 
> https://stackoverflow.com/questions/1591700/how-to-execute-a-wix-custom-action-dll-file-with-dependencies <https://stackoverflow.com/questions/1591700/how-to-execute-a-wix-custom-action-dll-file-with-dependencies>
> 
> https://blogs.msdn.microsoft.com/jasongin/2008/05/23/custom-action-project-templates/ <https://blogs.msdn.microsoft.com/jasongin/2008/05/23/custom-action-project-templates/>
> 
> 
> Have a nice day,
> Elena.
> 
> 
>> Il giorno 24 lug 2018, alle ore 15:49, Elena Aralla <elena.aralla at gmail.com <mailto:elena.aralla at gmail.com>> ha scritto:
>> 
>> 
>> Hi,
>> can you better explain this statement to me:
>> 
>> “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”?
>> 
>> Thank you.
>> 
>> 
>>> Il giorno 23 lug 2018, alle ore 18:21, Hoover, Jacob <Jacob.Hoover at greenheck.com <mailto:Jacob.Hoover at greenheck.com>> ha scritto:
>>> 
>>> 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 <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 <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 <mailto:wix-users at lists.wixtoolset.org>>
>>> Cc: Elena Aralla <elena.aralla at gmail.com <mailto:elena.aralla at gmail.com>>
>>> Subject: [wix-users] ERROR in custom action using sql CE
>>> 
>>> 
>>> 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 <http://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.
>>> 
>>> 
>>> ____________________________________________________________________
>>> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/ <http://www.firegiant.com/>
>> 
> 




More information about the wix-users mailing list