1627 - Microsoft.Deployment.WindowsInstaller.InstallerException: функция не выполнена во время выполнения - PullRequest
0 голосов
/ 09 октября 2019

Теперь проблема заключается в том, что когда я запускаю этот код в созданном MSI-файле, последний запрос, т.е. запрос отложенного запуска, становится неудачным и дает мне исключение с кодом ошибки MSI 1627:

Microsoft.Deployment.WindowsInstaller.InstallerException: функция не выполнена во время выполнения. в Microsoft.Deployment.WindowsInstaller.View.Execute (запись executeParams) в Microsoft.Deployment.WindowsInstaller.Database.Execute (String sql, Record record) в Microsoft.Deployment.WindowsInstaller.Database.Execute (String sqlFormat, Object [] args)в MSIManager.Program.UpdateMSIService (строка msi, строка serviceName, строка displayName, строка fileName) в C: \ Users \ Chirag Pathak \ 3D-объекты \ bizbrain-agent-v7 \ Installers \ MSIManager \ Program.cs: строка 96

Ниже приведен мой код

   class Program
            {
                private static int msidbServiceConfigEventInstall = 1;
                private static int SERVICE_CONFIG_DELAYED_AUTO_START = 3;

                private static string BIN_FILE_PATH_X64 = @"C:\Users\Chirag Pathak\3D Objects\bizbrain-agent-v7\x64\Debug\";
                private static string MSI_NAME_X64 = "MyTallyApp Agent Installer (x64).msi";

                private static string PATH_PREFIX = "C:\\Users\\Chirag Pathak\\3D Objects\\bizbrain-agent-v7\\Installers\\Installers\\";

        static void Main(string[] args)
                {
                    UpdateMSIService(MSI_NAME_X64, "BizBrainAgentWindowsService-x64", "MyTallyApp Agent Service (64 bit)", "BizBrainAgentWindowsService-x64.exe");
                    UpdateMSIService(MSI_NAME_X64, "BizBrainAgentWindowsServiceLauncher-x64", "MyTallyApp Agent Service Launcher (64 bit)", "BizBrainAgentWindowsServiceLauncher-x64.exe");

                }

              static bool UpdateMSIService(string msi, string serviceName, string displayName, string fileName)
                {
                    string databasePath = PATH_PREFIX + msi;
                    if (!File.Exists(databasePath))
                    {
                        Console.WriteLine("MSI File " + msi + " does not exist!");   
                        return false;
                    }

                    using(Database database = new Database(databasePath, DatabaseOpenMode.Direct))
                    {
                        try
                        {
                            serviceName = "'" + serviceName + "'";
                            displayName = "'" + displayName + "'";

                            Microsoft.Deployment.WindowsInstaller.View view = database.OpenView("Select Component_,FileName from File");
                            view.Execute();
                            Record[] records = view.ToArray<Record>();
                            string componentId = "'" + GetComponentId(records, fileName) + "'";
                            view.Close();
                            Console.WriteLine("Service ComponentId=:" + componentId);
                            //Do this after the search
                            fileName = "'" + fileName + "'";

                            string sqlDeleteServiceInstall = "DELETE FROM `ServiceInstall` WHERE `ServiceInstall`=" + serviceName;
                            database.Execute(sqlDeleteServiceInstall);


                            string sqlInsertServiceInstall = "INSERT INTO `ServiceInstall` (`ServiceInstall`,`Name`,`DisplayName`,`ServiceType`,`StartType`,`ErrorControl`,`Component_`,`Description`) VALUES (" + serviceName + "," + serviceName + "," + displayName + ",16,2,1," + componentId + "," + displayName + ")";
                            database.Execute(sqlInsertServiceInstall);

                            string sqlDeleteServiceControl = "DELETE FROM `ServiceControl` WHERE `ServiceControl`=" + serviceName;
                            database.Execute(sqlDeleteServiceControl);

                            string sqlInsertServiceControl = "INSERT INTO `ServiceControl` (`ServiceControl`,`Name`,`Event`,`Component_`) VALUES(" + serviceName + "," + serviceName + ",1," + componentId + ")"; 
                            database.Execute(sqlInsertServiceControl);


                  ****//For Automatic [Delayed Start]
                                string sqlInsertMSIServiceConfig = "INSERT INTO `MsiServiceConfig`(`MsiServiceConfig`,`Name`,`Event`,`ConfigType`,`Argument`,`Component_`) VALUES('AutoStartDelayed'," + serviceName + "," + msidbServiceConfigEventInstall + "," + SERVICE_CONFIG_DELAYED_AUTO_START + ",1," + componentId + ")";  
                                database.Execute(sqlInsertMSIServiceConfig);//****//This is the line where exception occures.
                            return true;

                        }
                        catch (Exception e)
                        { }
                    }  
                }

{"msiErrorCode": 1627, "ClassName": "Microsoft.Deployment.WindowsInstaller.InstallerException", "Message": "Ошибка функции во время выполнения.", "Данные ": ноль," InnerException ": ноль," HelpURL ": ноль," StackTraceString ":" в Microsoft.Deployment.WindowsInstaller.View.Execute (запись executeParams) \ r \ n в Microsoft.Deployment.WindowsInstaller.Database.Execute(Строка sql, запись записи) \ r \ n в Microsoft.Deployment.WindowsInstaller.Database.Execute (Строка sqlFormat, Object [] args) \ r \ n в MSIManager.Program.UpdateMSIService (String msi, String serviceName, String displayName, String fileName) в C: \ Users \ Chirag Pathak \ 3D-объекты \ bizbrain-agent-v7 \ Installers \ MSIManager \ Program.cs: строка 96 "," RemoteStackTraceString ": null,«RemoteStackIndex»: 0, «ExceptionMethod»: «8 \ nExecute \ nMicrosoft.Deployment.WindowsInstaller, версия = 3.0.0.0, культура = нейтральная, PublicKeyToken = ce35f76fcda82bad \ nMicrosoft.Deployment.WindowsInstaller.View \ nVoid Execute. (Microsoft.Dep). WindowsInstaller.Record)», "HResult": - 2146233087, "Источник": "Microsoft.Deployment.WindowsInstaller", "WatsonBuckets": нулевая}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...