Giter Site home page Giter Site logo

Comments (10)

PeterKottas avatar PeterKottas commented on June 28, 2024 2

Hi Andrew, don't worry, you're not spamming at all. On the contrary, good catch about the error! I'll make the change now and will upload new version so that you can give it a try. Will let you know once it's done

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on June 28, 2024 1

Awesome, glad we fixed it mate. Thanks for making this lib better! Spread the work and let me know if you need anything else ;)

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on June 28, 2024

Hey mate. 2 things come to mind afk. Try to omit "." when calling the service. Second thing to try would be running cmd/powershell as administrator. If that doesn't help, give this a read #12 . Tou might find some good points there. If nothing helps, I'll get back to to u tomorrow ;-)

from dotnetcore.windowsservice.

kharlamov avatar kharlamov commented on June 28, 2024

Yeah tried both of this things with no luck, I have simplified my app down to this, and again working locally not on the server:

        public static void Main(string[] args)
        {
            LogManager.Configuration = new XmlLoggingConfiguration(
                Path.Combine(AppContext.BaseDirectory, "NLog.config"), true);
            var logger = LogManager.GetCurrentClassLogger();

            Console.WriteLine("I am outputing.");
            ServiceRunner<MyWindowsServiceApplicationService>.Run(config =>
            {
                config.SetName("MyWindowsServiceApplication");
                var name = config.GetDefaultName();

                config.Service(serviceConfig =>
                {
                    serviceConfig.ServiceFactory(extraArguments => new MyWindowsServiceApplicationService());
                    Console.WriteLine("I am outputing.");

                    serviceConfig.OnStart((service, extraParams) =>
                    {
                        Console.WriteLine("I am not outputing.");
                    });

                    serviceConfig.OnStop(service =>
                    {
                    });

                    serviceConfig.OnError(e =>
                    {
                        Console.WriteLine(e);
                        logger.Error(e);
                    });

                });
            });
        }
    public class MyWindowsServiceApplicationService : IMicroService
    {

        public void Start()
        {

        }

        public void Stop()
        {
        }
    }

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on June 28, 2024

I looks kinda similar to that issue I've send you previously. Try to get the int that the run method returns. It should be 0 if it works properly.

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on June 28, 2024

Also get the app path this way : PlatformServices.Default.Application.ApplicationBasePath . That's what I use so it's worth trying.

from dotnetcore.windowsservice.

kharlamov avatar kharlamov commented on June 28, 2024

Updated the path (They seem to be reporting the same path.), the run method is returning a -1.

Ill read through the other ticket see if i can find what is causing my issue and report back. The annoying thing is that the only thing in the Start is Console.WriteLine and that is where the exception stack trace is ending.

Update: There is a lot to sift through in the other ticket but so far I have discovered:

  • When I run it without action:run, I am getting all the correct output.
  • When I run with action:run through powershell I get the exception I mentioned, but I get it logged in nlog and the console from the OneError callback.
  • When I manually run the service directly through the Services Window it just gets the same 1053 error and I don't get no log file with the error.
  • When I manually run the service directly through the Services Window with File.WriteAllText no files are generated.
  • I have the same sdk on the server and locally, I am running dotnet publish for getting the code up to the server.
  • This is what the path to the executable is setup as C:\Program Files\dotnet\dotnet.exe C:\Program Files\My Windows Service\MyWindowsServiceApplication.dll action:run

Alright, thats all the information I have, sorry if I have been spamming you.

from dotnetcore.windowsservice.

kharlamov avatar kharlamov commented on June 28, 2024

Amazing what a good nights sleep can do, I figured it out in my nightmares. The problem is the path and the command that gets generated.

Locally the command thats getting setup for the service is C:\Program Files\dotnet\dotnet.exe C:\Projects\MyWindowsServiceApplication\MyWindowsServiceApplication\bin\Debug\netcoreapp1.1\MyWindowsServiceApplication.dll action:run Notice no spaces to the DLL.

However on the server C:\Program Files\dotnet\dotnet.exe C:\Program Files\My Windows Service\MyWindowsServiceApplication.dll action:run has spaces in Program Files and My Windows Service which is making them invalid.

Is there anyway to fix this, could we wrap the second parameter in quotes in the action:install I am not sure if thats valid? From host = string.Format("{0} {1}", host, appPath); to host = string.Format("{0} \"{1}\"", host, appPath);:

host = string.Format("{0} {1}", host, appPath);

from dotnetcore.windowsservice.

PeterKottas avatar PeterKottas commented on June 28, 2024

Ok that's done and uploaded in v1.0.17 Let me know if it helps ;)

from dotnetcore.windowsservice.

kharlamov avatar kharlamov commented on June 28, 2024

Just tested up on the server works perfect, thank you so much 👍

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.