WIX install windows service
I want to install a Windows Service. With installutil.exe it is running fine but with WIX it stands still at "starting service"
<Component Id="CMP_Service" Feature="Core">
<File Source="$(var.Service.TargetPath)" KeyPath="yes"/>
<ServiceInstall Id="Service"
Name="Service"
Description="..."
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
Type="ownProcess"/>
<ServiceControl Id="ServiceControllELS"
Name="Service"
Start="install"
Stop="both"
Remove="uninstall"
Wait="yes" />
</Component>
I think it is installing the wrong service but don´t know. May someone help me?
See also questions close to this topic
-
How can a person get help in learning Redis Online
i have visited Redis official website and more other platforms for the tutorials but still i am unable to installation of Redis (in-memory data structure store). The README.md file at Github is also failed to let me complete install and play with Redis.
I am a beginner to Redis and needs some specific and easy guidence in learning or installing it to system and play with it.
-
Problem with downloading UnityHub: Installation aborted. Installation did not complete successfully
I have problem with downloading UnityHub. It says an error when I want to install it:
Installation aborted Installation did not complete successfully
I've tried start setup with admin rights, restarting PC, reinstall UnityHub but nothing worked. -
Anaconda Navigator not appearing after installation (Windows 10)
I've been trying to install the newest version of Anaconda on my computer running W10. The installation seems to work fine, but after it is done I can't get the Navigator (or anything else) to open. I created a folder named C:\Anaconda and installed there, to avoid issues with spaces in the name. Even going into that folder after installation and directly clicking the anaconda navigator file doesn't do anything - a window that looks like a command prompt very briefly flashes open and shuts down, with no error messages or anything.
I have tried restarting, changing where it is installed, and turning off my firewall. No success with any of them - what's my next steps?
-
WIX: Property value doesn't change from Publish element
I have created the following property:
<Property Id="InstallationType" Value="InstallComplete" ></Property>
I tried to change this property value according do button clicked in the UI:
<Control Id="TypicalButton" Type="PushButton" X="40" Y="65" Width="100" Height="37" ToolTip="!(loc.SetupTypeDlgTypicalButtonTooltip)" Default="yes" Text="!(loc.SetupTypeDlgTypicalButton)" IconSize="48" Property="InstallationType"> <Publish Property="WixUI_InstallMode" Value="InstallTypical">1</Publish> <Publish Property="InstallationType" Value="InstallTypical" >1</Publish> <Publish Event="SetInstallLevel" Value="1">1</Publish> </Control>
And then to include a feature depends on the property value:
<Feature Id="test" Title="test" Level="0" > <ComponentGroupRef Id="CompilationHeadset" /> <Condition Level="1">InstallationType="InstallTypical"</Condition> </Feature>
The problem is that when I click the "TypicalButton" it doesn't include the feature so I'm understand for it that the condition is false because the property value doesn't changed as it should be.
What I am doing wrong?
-
WIX custom action on failure not stopping the installation
Hello all I have gone through this article where they have written custom action by writing the entered values from the UI https://www.add-in-express.com/creating-addins-blog/2014/02/07/add-custom-dialogs-wix-installer/ I have update the custom action as follows
[CustomAction] public static ActionResult SaveUserInfo(Session session) { string name = session["FULLNAMEProperty"]; string email = session["EMAILProperty"]; if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(email)) return ActionResult.Failure; string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (!Directory.Exists(appdataPath + "\\Win App")) Directory.CreateDirectory(appdataPath + "\\Win App"); File.WriteAllText(appdataPath + "\\Win App\\registrationInfo.txt", name + "," + email); return ActionResult.Success; }
But this is not stopping the user, installation is getting succeed. Also how can I show the dialog to open and run the application after successful installation and choose the directory instead of the default directory
-
Wix - On upgradation of software, older version's registry is not getting removed
Previously Installshield was being used to create install and now I started using wix. I am new to wix and facing issue related to registry entry.
Lest say v1 = install created using install shield and v2 = install created using wix.
When v1 is already installed on machine and then if I try to upgrade using v2 install, all files, shortcuts of v1 gets deleted but registry doesn't. Because of this, entry of previous install is still shown in "Control Panel Items\Programs and Features". And ultimately entries of both v1 and v2 remains in the system.
Not sure what am I missing here. Upgrade codes of both v1 and v3 are equal.
<Product Id="$(var.Product_GUID)" Name="$(var.Product_FullName)" Language="1033" UpgradeCode="$(var.Upgrade_GUID)" Version="$(var.VersionNumber)" Manufacturer="$(var.ManufacturerName)"> <Package Id="$(var.Package_Code)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/> <Upgrade Id="$(var.Upgrade_GUID)"> <UpgradeVersion OnlyDetect="no" Property="OLDER_VERSION_FOUND" Minimum="1.0.0" /> </Upgrade> <MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MediaTemplate EmbedCab="yes" /> <Property Id="BrandName">$(var.BrandName)</Property> <Icon Id="ProgramIcon" SourceFile="$(var.ProgramIcon)"/> <!-- Add Remove Program Icon --> <Property Id="ARPPRODUCTICON" Value="ProgramIcon" /> <Feature Id="ProductFeature" Title="PCST_Product" Level="1"> <ComponentGroupRef Id="ComponentGroup_BasicFiles" /> </Feature> </Product>
-
how to implement retry mechanism when I got gsm modem Exception: No data received from phone?
public class GSMModemConnection { I made a windows service for receiving SMS I'm using Wavecom Gsm modem 1306B. But after some second I got an Exception: No data received from phone. I have searched in StackOverflow I found this link Exception: No data received from phone
someone pointed about to create a retry mechanism but I don't know how to implement it.
static void Main(string[] args) { GSMModemConnection gsm = new GSMModemConnection(); var result = gsm.OpenPort(); Console.WriteLine(result.PortName); while (true) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ShortMessage execResult = gsm.ReadSMS(result, "AT+CMGL=\"ALL\""); Console.WriteLine(execResult.Message); Console.WriteLine(execResult.Status); } }
public class GSMModemConnection { public AutoResetEvent receiveNow; //string strPortName, string strBaudRate public SerialPort OpenPort() { receiveNow = new AutoResetEvent(false); SerialPort port = new SerialPort(); port.PortName = "COM3"; port.BaudRate = 115200 /*Convert.ToInt32(strBaudRate)*/; //updated by Anila (9600) port.DataBits = 8; port.StopBits = StopBits.One; port.Parity = Parity.None; port.ReadTimeout = 300; port.WriteTimeout = 300; port.Encoding = Encoding.GetEncoding("iso-8859-1"); port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived); port.Open(); port.DtrEnable = true; port.RtsEnable = true; return port; } //Close Port public void ClosePort(SerialPort port) { port.Close(); port.DataReceived -= new SerialDataReceivedEventHandler(port_DataReceived); port = null; } //Execute AT Command public string ExecCommand(SerialPort port, string command, int responseTimeout, string errorMessage) { try { //receiveNow = new AutoResetEvent(); port.DiscardOutBuffer(); port.DiscardInBuffer(); receiveNow.Reset(); port.Write(command + "\r"); //Thread.Sleep(3000); //3 seconds string input = ReadResponse(port, responseTimeout); if ((input.Length == 0) || ((!input.EndsWith("\r\n> ")) && (!input.EndsWith("\r\nOK\r\n")))) throw new ApplicationException("No success message was received."); return input; } catch (Exception ex) { throw new ApplicationException(errorMessage, ex); } } //Receive data from port public void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (e.EventType == SerialData.Chars) receiveNow.Set(); } public string ReadResponse(SerialPort port, int timeout) { string buffer = string.Empty; do { if (receiveNow.WaitOne(timeout, false)) { string t = port.ReadExisting(); buffer += t; } else { if (buffer.Length > 0) throw new ApplicationException("Response received is incomplete."); else throw new ApplicationException("No data received from phone."); } } while (!buffer.EndsWith("\r\nOK\r\n") && !buffer.EndsWith("\r\n> ") && !buffer.EndsWith("\r\nERROR\r\n")); return buffer; } public ShortMessage ReadSMS(SerialPort port, string p_strCommand) { // Set up the phone and read the messages ShortMessage messages = null; try { #region Execute Command // Check connection var a = ExecCommand(port, "AT", 300, "No phone connected"); // Use message format "Text mode" var b = ExecCommand(port, "AT+CMGF=1\r", 300, "Failed to set message format."); // Use character set "PCCP437" //var c = ExecCommand(port, "AT+CSCS=\"PCCP437\"", 300, "Failed to set character set."); // Select SIM storage //var d = ExecCommand(port, "AT+CPMS=\"SM\"", 300, "Failed to select message storage."); // Read the messages string input = ExecCommand(port, p_strCommand, 5000, "Failed to read the messages."); #endregion #region Parse messages messages = ParseMessages(input); #endregion } catch (Exception ex) { throw ex; } if (messages != null) return messages; else return null; } public ShortMessage ParseMessages(string input) { ShortMessage msg = new ShortMessage(); //ShortMessageCollection messages = new ShortMessageCollection(); try { Regex r = new Regex(@"\+CMGL: (\d+),""(.+)"",""(.+)"",(.*),""(.+)""\r\n(.+)\r\n"); Match m = r.Match(input); while (m.Success) { //msg.Index = int.Parse(m.Groups[1].Value); msg.Index = int.Parse(m.Groups[1].Value); msg.Status = m.Groups[2].Value; msg.Sender = m.Groups[3].Value; msg.Alphabet = m.Groups[4].Value; msg.Sent = m.Groups[5].Value; msg.Message = m.Groups[6].Value; //messages.Add(msg); m = m.NextMatch(); } } catch (Exception ex) { throw ex; } return msg; } }
-
.NET Assembly.Load/LoadFrom fails if calling it within a windows service .net executable
Hi Devs!
I'm currently a bit lost in loading a specific assembly using "Assembly.Load" or "Assembly.LoadFrom" within my WPF application during runtime.
Loading the assembly during runtime works if i just run the executable!
But it throws an exception "FileNotFoundException, Could not load file or assembly .. or one of it dependencies.." if I load the same assembly the same way with my WPF application running as windows service (under LocalSystem).
processInstaller.Account = ServiceAccount.LocalSystem; processInstaller.Username = null; processInstaller.Password = null;
The assembly causing the exception is called "Siemens.Sinumerik.Operate.Services.Wrapper.dll" which is referenced by "Siemens.Sinumerik.Operate.Services.dll".
-> 3rd party assembly - no source available and for me it seems the wrapper is a mixed cli/c++ assembly.
Now after some research to this issue, I found out that .e.g maybe the lookup directory for assemblies is "C:\windows\system32" instead of the folder where the exceutable is stored. Or to take "fuslogvw" to narrow down the issue.
However its not my first project loading assemblies during runtime for some execution. Only thing is i never loaded a mixed "cli/c++" assembly during runtime -> There may be any known issues or something i may miss to load the "cli/c++" assembly correctly ?
Here is the code i use to load the assembly (either from file or gac)
LoadAssembly("Siemens.Sinumerik.Operate.Services"); // this assembly references the wrapper LoadAssembly("Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.8.2.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee", false); // load the wrapper from GAC using AssemblyName -> Exception only in service LoadAssembly("Siemens.Sinumerik.Operate.Services.Wrapper"); // load the wrapper from file using AssemblyName -> Exception only in service
LoadAssembly is checking whether the AssemblyName is already loaded in the current AppDomain and if not, its getting loaded either using GAC or FileSystem (depends on 2nd parameter "loadFromFile" of function LoadAssembly).
Thus it uses either
"Assembly.Load(assemblyName); // from gac"
or"Assembly.LoadFrom(file); // from file"
What I have tried to fix the issue:
Referencing the dynamically loaded assemblys to the main-project with the hope the application is able to load the wrapper assembly into the AppDomain during startup -> fail
changing current directory to the path where the wrapper assembly dll is stored -> fail
hooking up all AssemblyLoad and Resolve events and trying to load using "Assembly.Load" -> fail
compared the AppDomains used either for the Service and the normal Executable -> seems both are liky the same didnt see any special difference between them) -> fail
using "fuslogvw" to get some Assembly-Binding information which may indicates any error -> fail (see logs below)
Additionally I used "fuslogvw" to find out what the hell is going wrong for the wrapper, but i dont get any clue as the log shows the same result as if I just run the normal executable (which works not as service) Here is the log "Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.8.2.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee.HTM":
*** Protokolleintrag für Assembly-Binder (13.12.2019 @ 12:12:21) *** Der Vorgang wurde durchgeführt. Ergebnis der Bindung: hr = 0x0. Der Vorgang wurde erfolgreich beendet. Der Assemblymanager wurde geladen aus: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Als EXE-Datei ausgeführt. C:\Projekte\MTF\trunk\MTFMain\MTF\bin\Debug\MTF.exe --- Ein detailliertes Fehlerprotokoll folgt. === Zustandsinformationen vor Bindung === LOG: DisplayName = Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.8.2.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee (Fully-specified) LOG: Appbase = file:///C:/Projekte/MTF/trunk/MTFMain/MTF/bin/Debug/ LOG: Ursprünglicher PrivatePath = NULL LOG: DynamicBase = NULL LOG: CacheBase = NULL LOG: AppName = MTF.exe Aufruf von Assembly : MTF, Version=2.0.7286.21871, Culture=neutral, PublicKeyToken=null. === LOG: Diese Bindung startet im default-Load-Kontext. LOG: Die Anwendungskonfigurationsdatei wird verwendet: C:\Projekte\MTF\trunk\MTFMain\MTF\bin\Debug\MTF.exe.Config LOG: Die Hostkonfigurationsdatei wird verwendet: LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet. LOG: Verweis nach der Richtlinie: Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.8.2.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee LOG: Die Assembly wurde bei Suche im GAC gefunden. LOG: Die Bindung war erfolgreich. Assembly wird zurückgegeben von C:\Windows\assembly\GAC_32\Siemens.Sinumerik.Operate.Services.Wrapper\4.8.2.0__bdd90fa02fd1c4ee\Siemens.Sinumerik.Operate.Services.Wrapper.dll. LOG: Die Assembly wird im default-Load-Kontext geladen.
Here is the "WhereRefBind!Host=(LocalMachine)!FileName=(Siemens.Sinumerik.Operate.Services.Wrapper.dll).HTM":
*** Protokolleintrag für Assembly-Binder (13.12.2019 @ 12:14:00) *** Der Vorgang wurde durchgeführt. Ergebnis der Bindung: hr = 0x0. Der Vorgang wurde erfolgreich beendet. Der Assemblymanager wurde geladen aus: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Als EXE-Datei ausgeführt. C:\Projekte\MTF\trunk\MTFMain\MTF\bin\Debug\MTF.exe --- Ein detailliertes Fehlerprotokoll folgt. === Zustandsinformationen vor Bindung === LOG: Where-ref-Bindung. Speicherort = C:\Projekte\MTF\trunk\MTFMain\MTF\bin\Debug\dll\Siemens.Sinumerik.Operate.Services.Wrapper.dll LOG: Appbase = file:///C:/Projekte/MTF/trunk/MTFMain/MTF/bin/Debug/ LOG: Ursprünglicher PrivatePath = NULL LOG: DynamicBase = NULL LOG: CacheBase = NULL LOG: AppName = MTF.exe Aufruf von Assembly : (Unknown). === LOG: Diese Bindung startet im LoadFrom-Load-Kontext. WRN: Das native Image wird nicht im LoadFrom-Kontext durchsucht. Das native Image wird nur im Standard-Load-Kontext durchsucht, z. B. Assembly.Load(). LOG: Die Anwendungskonfigurationsdatei wird verwendet: C:\Projekte\MTF\trunk\MTFMain\MTF\bin\Debug\MTF.exe.Config LOG: Die Hostkonfigurationsdatei wird verwendet: LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet. LOG: Download von neuem URL file:///C:/Projekte/MTF/trunk/MTFMain/MTF/bin/Debug/dll/Siemens.Sinumerik.Operate.Services.Wrapper.dll. LOG: Der Assembly-Download wurde durchgeführt. Datei-Setup wird begonnen: C:\Projekte\MTF\trunk\MTFMain\MTF\bin\Debug\dll\Siemens.Sinumerik.Operate.Services.Wrapper.dll. LOG: Die von der Quelle ausgeführte Setup-Phase beginnt. LOG: Der Assemblyname ist: Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.8.2.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee. LOG: Die Richtlinie wird für where-ref-Bindung erneut angewendet. LOG: Verweis nach der Richtlinie: Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.8.2.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee LOG: Die Assembly wurde bei Suche im GAC gefunden. LOG: Wechseln vom LoadFrom-Kontext zum Standardkontext. LOG: Die Bindung war erfolgreich. Assembly wird zurückgegeben von C:\Windows\assembly\GAC_32\Siemens.Sinumerik.Operate.Services.Wrapper\4.8.2.0__bdd90fa02fd1c4ee\Siemens.Sinumerik.Operate.Services.Wrapper.dll. LOG: Die Assembly wird im default-Load-Kontext geladen.
I hope someone can help me narrowing down the loading issue with the Wrapper assembly :) or have any other ideas what i can do else..
Thank you so far!! Let me know if you need some futher information!
-
Windows service to run set of dependent process in multicore processor
I need to implement a windows service which will perform the following steps in sequence :
- Read from "Pending" table in SQL.
- Fetch the pending records from above step 1.
- Do some validation on the fetched records and some internal processing.
- The final prepared data will be stored in a table in SQL for consumption of another process.
Now, the windows service will be hosted in the machine where the processor has four cores.
Can I write my windows service using TPL in such a way that all the four cores can be utilised to process the above steps.
Following is the snapshot of Pending table.
All the records need to be processed as mentioned in above steps (1-4).
Now the records of the Pending tables will be distributed among the four cores and processing will be done. Using TPL can this be achieved ?
Currently using thread this I have written this.
private void RunWorkers(IEnumerable<IWorker> workers) { _logger.Debug(APP_AREA, "Running Workers"); foreach (var worker in workers) { worker.Run(); } } private IList<IWorker> CreateWorkers() { _logger.Debug(APP_AREA, "Creating Workers"); var workers = new List<IWorker>(); for (int workerId = 0; workerId != _Environment.ProcessorCount ; workerId++) { workers.Add(CreateWorker(workerParameters, CreateWorkerInterfaces(workerParameters))); } RunWorkers(workers); } public void Run() { AbortThread(); _logger.Info(APP_AREA, "Running Worker {0}", WorkerParameters.WorkerId); //IsBackground = true, When the process dies the thread dies too _workerThread = new Thread(ProcessThreadLoop) { IsBackground = true }; _workerThread.Start(true); } private void ProcessThreadLoop(object continuousLoop) { Aborted = false; bool continueLooping = true; while (continueLooping && !Aborted) { try { Process(); // This is doing the steps mentioned in Step 1-4 Sleep(); } catch () { // catch code } continueLooping = (bool) continuousLoop; } }
But I want to implement the same using TPL feature of .NET framework. I am very new to TPL . Following the link Basic design pattern for using TPL inside windows service for C# for the start/stop of the service. Any guidance will be greatly appreciated.
-
How to rename the base file element name under component during hotfix using windows installer?
In base version of my setup, by mistakenly i added the same name for two files like:
<component id="x" GUID="guid value"> <file id="x" source="c:\files\x.dll" name="x.dll"> </component> <component id="y" GUID="another guid value"> <file id="y" source="c:\files\y.dll" name="x.dll"> </component>
Now I want to change the name to "y.dll" for the file with id="y" using HotFix.
If we change the name directly, the compiler error has been thrown "Component "y" has a changed keypath in the transform 'C:\Patches\diff.wixmst'. Patches cannot change the keypath of a component.
Please suggest me know how to change the file name using hotfix?
-
How to rename the name of the file under component during hotfix using wix bootstrapper?
In base version of my setup, by mistakenly i added the same name for two files like:
<file id="x" source="c:\files\x.dll" name="x.dll"> </component> <component id="y" GUID="another guid value"> <file id="y" source="c:\files\y.dll" name="x.dll"> </component>``` And released the product. Now I want to change the name to "y.dll" for the file with id="y" using HotFix. Please let me know how to change the file name using hotfix? If we change the name directly, the compiler error has been thrown like "removed name x.dll for GUID="another guid value""
-
In my Windows WiX Installer my Custom Actions don't run
I want to have the installer/uninstaller remove a folder that contains content generated by the application at run time. I figured a Custom Action would be the way to go.
We are using WiX 3.6.
(I want it in the installer sequence for a specific reason that is not important to this question.)
Here is my CustomAction definitions in the xml:
<Binary Id="CustomActionLib" SourceFile="$(var.CustomActionLibrary.TargetDir)$(var.CustomActionLibrary.TargetName).CA.dll" /> <CustomAction Id="DeleteLocalizedCA" Impersonate="yes" BinaryKey="CustomActionLib" DllEntry="DeleteLocalized" Return="check" /> <CustomAction Id="DeleteResourcesCA" Impersonate="yes" BinaryKey="CustomActionLib" DllEntry="DeleteResources" Return="check" />
Here are my references to them:
<InstallExecuteSequence> <Custom Action="DeleteLocalizedCA" Before="InstallFiles"/> <FindRelatedProducts Before="LaunchConditions" /> <RemoveExistingProducts After="InstallFinalize" /> <RemoveShortcuts>Installed AND NOT UPGRADINGPRODUCTCODE</RemoveShortcuts> </InstallExecuteSequence> <InstallUISequence> <Custom Action="DeleteLocalizedCA" Before="InstallFiles"/> <FindRelatedProducts Before="LaunchConditions" /> </InstallUISequence>
I added the CustomActionLibrary project to the solution and added a reference to it from the installer project but it never runs, I never see it in the logs, nothing!
And thus my question, Why Don't my WiX Custom Actions Run?