Giter Site home page Giter Site logo

Comments (11)

RamazanBIYIK avatar RamazanBIYIK commented on July 30, 2024

Same issue. I used "New-Service -Name MyServiceName -BinaryPathName "C:\Users\Ramazan\source\repos\AlertMailWindows
ServiceonCoreConsole\run.bat action:run" -StartupType Automatic" to install service.(There is only "dotnet run" command inside batch file )I am dealing with a database that will check the parameters and notify somebody via e mail. I wrote classes and make a base class. I called baseclass inside Start method and used a timer(to check database every 30 sec. ). Also ı used " Microsoft.Extensions.Logging" nuget package.

from dotnetcore.windowsservice.

Patryx avatar Patryx commented on July 30, 2024

So how your CustomAction look like and the InstallExecuteSequence?
Is it possible to use 'dotnet run action:install' directly in ExeCommand? And how do unistall service before uninstalling (CustomAction in WIX). After building project I have *.exe file. Do you have it too?

from dotnetcore.windowsservice.

RamazanBIYIK avatar RamazanBIYIK commented on July 30, 2024

I finally get it worked. First of all install peter's repo. There is an example project there. It worked fine in my computer so the problem was on my project.

The steps ı followed:
1-) There was a class inside peter's repo. And there was timer so ı needed that class ı just modify it for myself,
2-)Open CMD and type: dotnet yourdll.dll action:run ı get an error that saying "The service process could not connect to the service controller" . Dont lose hope :D
3-) Then ı typed dotnet YourDll.dll action:install

Now ı ll try my service and let you know if it is working

from dotnetcore.windowsservice.

RamazanBIYIK avatar RamazanBIYIK commented on July 30, 2024

It didn't work as ı expected :( Probably the problem is inside my codes.

from dotnetcore.windowsservice.

Patryx avatar Patryx commented on July 30, 2024

Remember to put everything in thread/timer etc. OnStart has to be finished quickly :)

from dotnetcore.windowsservice.

RamazanBIYIK avatar RamazanBIYIK commented on July 30, 2024

I think ı put. I logged information to text files. ı used a locker object for not crash threads,(timer set as 1 sec and my operation takes 5 sec). While you are saying thread/timer you mean tasks? I didn't used tasks structer in my project. My project have 3 stage after get inside ElapsedEventArgs class
1-)Get a list from SQL datatable where parameters false.
2-) get that parameters ID and send notification via email.
3-) update paramaters to true.

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on July 30, 2024

Guys please follow the docs in the readme. You should never use New-Service -Name, if you could there would be no need for this lib. dotnet YourDll.dll action:install is indeed the right way. Start simple to make sure the lib is working. Then add more things. Make sure you run as admin. The timer service should indeed be good starting point for you judging by your requirements.

from dotnetcore.windowsservice.

RamazanBIYIK avatar RamazanBIYIK commented on July 30, 2024

I think ı put. I logged information to text files. ı used a locker object for not crash threads,(timer set as 1 sec and my operation takes 5 sec). While you are saying thread/timer you mean tasks? I didn't used tasks structer in my project. My project have 3 stage after get inside ElapsedEventArgs class
1-)Get a list from SQL datatable where parameters false.
2-) get that parameters ID and send notification via email.
3-) update paramaters to true.
4-)Repeat that sequence every 20 sec.

Everything was goin fine . Service get inside ElapsedEventArgs class. But while it is counting the false paramater inside sql table it is doing nothing. I am confirmed that with a textfile. It cant pass that line.

from dotnetcore.windowsservice.

Patryx avatar Patryx commented on July 30, 2024

Peter, after correcting my source codes of service, I resolved the problem with WIX installer in a bit different way (I did it before your answer).
In VS2017 as a result of compilation of Console Appliaction (let's say "TestApp") I get "TestApp.exe" file and "TestApp.dll". I don't know why there is also an exe file but in WIX installer I use two CustomAction's:

  • one to install service after installing files as: "TestApp.exe action:install name:'TestService'"
  • second one to uninstall service just before uninstalling files as: "TestApp.exe action:uninstall name:'TestService'".

It seems to work now. Do you see any dangers? Maybe I shouldn't get and use *.exe application (I don't know why it is generated and it isn't in your example...) in this way to install and uninstall the service.
Please give me your opinion.
Thanks in advance.

from dotnetcore.windowsservice.

dotnetcraig avatar dotnetcraig commented on July 30, 2024

@Patryx You probably get the exe because of dotnet publish configuration as release and runtime being win64.

The only "danger" with this way of doing is that the wix installer doesn't support it and handle the responses properly. For instance, my bootstrapper installs .Net Framework 4.6.2 on an older system, but the registry isn't updated until after a system is restarted. The "action:install" sends the installer an error code because of the just mentioned state of the .net framework, but the self contained genius of dotnet actually runs successfully, installing the service but tells the user differently.

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on July 30, 2024

Good job again! Glad we have a wix expert in da house as it seems people are using it.

from dotnetcore.windowsservice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.