A Hello World Service in ServiceStack and .NET using SharpDevelop

1. Download and install SharpDevelop. SharpDevelop is a free and open-source development environment for Microsoft .NET. As of this writing, the latest installer is available at the URL “http://www.icsharpcode.net/OpenSource/SD/Download/#SharpDevelop4x“.

2. Download ServiceStack. ServiceStack is an open-source framework for implementing REST services. As of this writing, the latest versions of the .dlls are available in an archive file of sample code named “ServiceStack.Examples-master.zip” at the URL “https://github.com/ServiceStack/ServiceStack.Examples/“. Note that the ServiceStack site itself recommends using the NuGet package manager built into Visual Studio to get ServiceStack instead.

3. Extract the downloaded .zip file into any convenient location, then navigate down into the “lib” folder and locate the ServiceStack .dll files within it.

4. Start SharpDevelop.

5. Select the item “Main – New – Solution” from SharpDevelop’s main menu bar. The “New Project” dialog will appear.

6. In the “Categories” pane of the New Project dialog, select the tree item “C# – Windows Applications”. The contents of the “Templates” pane will change to display the available template types.

7. In the Templates pane, click the item named “Console Application” to select it.

8. In the Name box, enter the value “ServiceStackHelloWorldService”.

9. Click the Create button. The New Project dialog will be dismissed, focus will return to the main SharpDevelop window, and the structure of the newly created solution will be displayed in the “Projects” pane that (by default) is docked on the left side of the window.

10. Right click the node for the ServiceStackHelloWorldService project (not the node for the solution of the same name, which is its parent) and select the “Add Reference” item from the menu that appears. The “Add Reference” dialog will appear.

11. On the Add Reference dialog, click the tab named “.NET Assembly Browser”, then the “Browse” button. A Windows Explorer dialog titled “Open” will appear.

12. In the Open dialog, select the ServiceStack .dlls which were located in a previous step and then click the “Open” button. The Open dialog will be dismissed and focus will return to the Add Reference dialog, where the specified .dlls will be listed in the “Selected References” pane.

13. Click the OK button the Add Reference dialog to dismiss it and add the specified references to the project. Focus will return to the main SharpDevelop window.

14. Replace the automatically-generated contents of the Program.cs file with the text below and save. Note that this code is very minimally adapted from a sample found at the URL “https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting“.

using System;
using ServiceStack.ServiceInterface;
using ServiceStack.WebHost.Endpoints;

class Program

	// This code is minimally adpated from a sample found at the URL
	// "https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting".

	public class Hello
		public string Name { get; set; }

	public class HelloResponse
		public string Result { get; set; }

	public class HelloService : Service
		public object Any(Hello request)
			return new HelloResponse { Result = "Hello, " + request.Name + "!" };

	//Define the Web Services AppHost
	public class AppHost : AppHostHttpListenerBase
		public AppHost() : base("StarterTemplate HttpListener", typeof(HelloService).Assembly) { }

		public override void Configure(Funq.Container container)

	//Run it!
	static void Main(string[] args)
		var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];
		var appHost = new AppHost();
		Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, listeningOn);

15. Build and execute the application by selecting the “Project – Run Project” item from the main menu bar, or by pressing the F5 key. The code will be compiled, and a console window will appear that displays the message “AppHost Created at [current date and time], listening on http://*:1337“.

16. Open a web browser and navigate to the URL “http://localhost:1337/Hello/world“. A web page that contains the text, “Hello, world!” will be loaded.


  • You could obviously also use Visual Studio for this, if you’d like. Or maybe even MonoDevelop.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

3 Responses to A Hello World Service in ServiceStack and .NET using SharpDevelop

  1. Diana says:

    The type or namespace name ‘Service’ could not be found (are you missing a using directive or an assembly reference?) Same for AppHostHttpListenerBase and Funq.

    • Romain says:

      You need to add the references to the project: ServiceStack, ServiceStack.Interfaces, ServiceStack.ServiceInterface (with ServiceStack v3 it worked)

  2. Romain says:

    This helped me greatly, thanks ! Here is what I’m using (ServiceStack v3): http://www.hostingpics.net/viewer.php?id=934833Exemplecode.png

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s