From 884c40cfea959cb1a023ab902cdc1dc080c9869a Mon Sep 17 00:00:00 2001 From: Jef Claes Date: Mon, 11 May 2020 08:24:59 +0200 Subject: [PATCH] Restoring post that has some GA hits --- cannot-start-service-from-command-line.html | 169 ++++++++++++++++++++ feeds/posts/default | 11 ++ page/23/index.html | 44 ++--- page/24/index.html | 22 +++ post/feeds/posts/default | 11 ++ post/index.html | 20 +++ sitemap.xml | 5 + tags/code/feeds/posts/default | 11 ++ tags/code/index.html | 20 +++ tags/index.html | 2 +- 10 files changed, 292 insertions(+), 23 deletions(-) create mode 100644 cannot-start-service-from-command-line.html diff --git a/cannot-start-service-from-command-line.html b/cannot-start-service-from-command-line.html new file mode 100644 index 0000000..a137cad --- /dev/null +++ b/cannot-start-service-from-command-line.html @@ -0,0 +1,169 @@ + + + + + Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. - Jef Claes + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + Jef Claes + +
+ +

Jef Claes

+

On software and life

+ + +
+ + +
+
+ +
+
+ 13 + Mar 2010 +
+
+ +
+

Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe)..

+
+
+ +
+

When you create a new Windows Service project and try to debug it, +Visual Studio will show you a Windows Service Start Failure with the +message Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe) and then started with the Server Explorer, Windows Services Administrative tool or the NET START command..

+


+The trick my team and I use to workaround this problem, makes use of the +service Debug flag. If the Debug flag is on, we just start the service +by using our own public Start method. When the OnStart event is fired in +the service itself, we call the same public Start method.

+

This goes in your service.

+
protected override void OnStart(string[] args)
+{
+    Start();
+}
+
+public void Start()
+{
+    //Start!
+}
+

And this goes in Program.cs.

+
namespace UdpListener
+{
+    static class Program
+    {
+        static void Main()
+        {
+            #if (!DEBUG)
+                ServiceBase[] ServicesToRun;
+                ServicesToRun = new ServiceBase[] 
+                { 
+                    new UdpListener() 
+                };
+
+                ServiceBase.Run(ServicesToRun);
+            #else
+                UdpListener listener = new UdpListener();
+
+                listener.Start();
+            #endif           
+        }
+    }
+}
+

You can set the Debug flag of your service in your service properties.

+

+

The only problem with this solution is that you can’t debug your OnStop +event but this hasn’t been an issue for us so far.

+ +
+ +
+ + + + + +
+
+ + + + + + + + diff --git a/feeds/posts/default b/feeds/posts/default index 9b623df..7340c82 100644 --- a/feeds/posts/default +++ b/feeds/posts/default @@ -2269,6 +2269,17 @@ System.Func<Exception, Boolean> predicate The predicate to execute Roadtrippin’ Minutes after leaving home we discovered an unpleasant surprise; my Tom Tom has no map of the Czech Republic. Good thing that people used to print this stuff on paper. After consulting a paper map of Europe we did have an idea which direction to follow. + + Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. + https://jefclaes.be/cannot-start-service-from-command-line.html + Sat, 13 Mar 2010 16:36:00 +0100 + + https://jefclaes.be/cannot-start-service-from-command-line.html + When you create a new Windows Service project and try to debug it, Visual Studio will show you a Windows Service Start Failure with the message Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe) and then started with the Server Explorer, Windows Services Administrative tool or the NET START command.. + +The trick my team and I use to workaround this problem, makes use of the service Debug flag. + + Book review: Object-Oriented JavaScript https://jefclaes.be/2010/02/book-review-object-oriented-javascript.html diff --git a/page/23/index.html b/page/23/index.html index dc361e6..646ee12 100644 --- a/page/23/index.html +++ b/page/23/index.html @@ -130,6 +130,28 @@

+
+
+
+
+ 13 + Mar 2010 +
+
+
+

+ Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. +

+ + + When you create a new Windows Service project and try to debug it, +Visual Studio will show you a Windows Service Start F... + + +
+
+
+
@@ -264,28 +286,6 @@

-
-
-
-
- 17 - Nov 2009 -
-
-
-

- Book review: Professional Refactoring in C# & ASP.NET -

- - - Three months ago I was looking up to refactoring a legacy ASP.NET -Webforms application. Although I was familiar with ref... - - -
-
-
-
    diff --git a/page/24/index.html b/page/24/index.html index 83cf81b..7b3e5a3 100644 --- a/page/24/index.html +++ b/page/24/index.html @@ -64,6 +64,28 @@

    Jef Claes

    +
    +
    +
    +
    + 17 + Nov 2009 +
    +
    +
    +

    + Book review: Professional Refactoring in C# & ASP.NET +

    + + + Three months ago I was looking up to refactoring a legacy ASP.NET +Webforms application. Although I was familiar with ref... + + +
    +
    +
    +
    diff --git a/post/feeds/posts/default b/post/feeds/posts/default index a0cd6c2..5a58fa4 100644 --- a/post/feeds/posts/default +++ b/post/feeds/posts/default @@ -2269,6 +2269,17 @@ System.Func<Exception, Boolean> predicate The predicate to execute Roadtrippin’ Minutes after leaving home we discovered an unpleasant surprise; my Tom Tom has no map of the Czech Republic. Good thing that people used to print this stuff on paper. After consulting a paper map of Europe we did have an idea which direction to follow. + + Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. + https://jefclaes.be/cannot-start-service-from-command-line.html + Sat, 13 Mar 2010 16:36:00 +0100 + + https://jefclaes.be/cannot-start-service-from-command-line.html + When you create a new Windows Service project and try to debug it, Visual Studio will show you a Windows Service Start Failure with the message Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe) and then started with the Server Explorer, Windows Services Administrative tool or the NET START command.. + +The trick my team and I use to workaround this problem, makes use of the service Debug flag. + + Book review: Object-Oriented JavaScript https://jefclaes.be/2010/02/book-review-object-oriented-javascript.html diff --git a/post/index.html b/post/index.html index 6e15b87..1cbd412 100644 --- a/post/index.html +++ b/post/index.html @@ -4578,6 +4578,26 @@

  • +
    +
    +
    + 13 + Mar 2010 +
    +
    +
    +

    + Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. +

    + + + When you create a new Windows Service project and try to debug it, +Visual Studio will show you a Windows Service Start F... + + +
    +
    +
  • diff --git a/sitemap.xml b/sitemap.xml index ab22189..9a95409 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1177,6 +1177,11 @@ 2010-04-12T20:16:00+02:00 + + https://jefclaes.be/cannot-start-service-from-command-line.html + 2010-03-13T16:36:00+01:00 + + https://jefclaes.be/2010/02/book-review-object-oriented-javascript.html 2010-02-22T19:47:00+01:00 diff --git a/tags/code/feeds/posts/default b/tags/code/feeds/posts/default index a4451ae..4ce6c1d 100644 --- a/tags/code/feeds/posts/default +++ b/tags/code/feeds/posts/default @@ -935,6 +935,17 @@ System.Func<Exception, Boolean> predicate The predicate to execute Doing batch operations and elegantly handling exceptions is a problem which every developer has faced before. In .NET 3.5 or older there is no out-of-the-box solution to handle exceptions in these types of scenarios, without being inconsistent to the normal flow of exception handling. .NET 4 introduces the AggregateException; an exception representing multiple exceptions. The AggregateException was introduced in the first place to be used with the parallel framework, but it can be used in other scenarios as well, such as batch operations. + + Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. + https://jefclaes.be/cannot-start-service-from-command-line.html + Sat, 13 Mar 2010 16:36:00 +0100 + + https://jefclaes.be/cannot-start-service-from-command-line.html + When you create a new Windows Service project and try to debug it, Visual Studio will show you a Windows Service Start Failure with the message Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe) and then started with the Server Explorer, Windows Services Administrative tool or the NET START command.. + +The trick my team and I use to workaround this problem, makes use of the service Debug flag. + + Webforms lessons learned the hard way (Part 2) https://jefclaes.be/2010/02/webforms-lessons-learned-hard-way-part_15.html diff --git a/tags/code/index.html b/tags/code/index.html index 2ed5fd4..67b09d8 100644 --- a/tags/code/index.html +++ b/tags/code/index.html @@ -1890,6 +1890,26 @@

  • +
    +
    +
    + 13 + Mar 2010 +
    +
    +
    +

    + Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe).. +

    + + + When you create a new Windows Service project and try to debug it, +Visual Studio will show you a Windows Service Start F... + + +
    +
    +
  • diff --git a/tags/index.html b/tags/index.html index e4dc72c..7685e26 100644 --- a/tags/index.html +++ b/tags/index.html @@ -72,7 +72,7 @@

    Tags

    - code94 + code95