Built something? We create video reels & spotlights for GitHub projects.Promote your project →
Home / Developers / prabhakarpandey
Developer Profile

prabhakarpandey

Discovered public repositories for prabhakarpandey in the GitHub catalog.

↗

prabhakarpandey/Not-ablle-to-install-window-service-by-using-TopShelf

I am creating a window service by using console application.Below is my code: namespace ConsoleApplication1 { //public class topshelf //{ // readonly Timer _timer; // public topshelf() // { // _timer = new Timer(10) { AutoReset = true}; // _timer.Elapsed += (sender, eventArgs) => Console.WriteLine("It is {0} an all is well", DateTime.Now); // } // public void Start() { _timer.Start(); } // public void Stop() { _timer.Stop(); } //} public class MyService : IService { public void Start() { Console.WriteLine("Running..."); } public void Stop() { Console.WriteLine("Done!"); } } public class Program { public static void Main(string[] args) { HostFactory.Run(x => //1 { x.Service<MyService>(s => //2 { s.ConstructUsing(name => new MyService()); //3 s.WhenStarted(tc => tc.Start()); //4 s.WhenStopped(tc => tc.Stop()); //5 }); x.RunAsLocalSystem(); //6 x.SetDescription("Sample Topshelf Host"); //7 x.SetDisplayName("MyService"); //8 x.SetServiceName("MyService"); //9 }); } } } PM> MySrvice.exe install gives error The term 'MyService.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling o f the name, or if a path was included, verify that the path is correct and try again. At line:1 char:14 + MyService.exe <<<< install + CategoryInfo : ObjectNotFound: (MyService.exe:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

FOR MAINTAINERS

Built something? Put it in front of millions of developers.

We make a short reel about your project and post it across YouTube, Instagram, Threads, and X. Send a link, we do the rest.

SPONSORED Sponsored Partner