Servicestack F# template Update. Circle is Complete

Explore the new ServiceStack F# templates now available on Visual Studio Gallery. Learn about four hosting options and why version 3.71 is recommended.

4 min read 663 words

Few days back I wrote an article about how I created side waffle templates for Servicestack.

Yesterday, Daniel Mohl merged the pull request, added the missing bits to make it work, and it is now up on Visual Studio Gallery. I seriously like to thank Daniel for this work and support even after his own hectic schedule with his day job. And a big thanks to the wonderful members of the F# community.

Here, I am sharing a few details of the template I have created.

There are four templates available now.

  1. Servicestack with Asp.Net host
  2. Servicestack with Asp.Net host and Razor Engine
  3. Servicestack with Self host
  4. Servicestack with Self host and Razor Engine

I was working on Asp.Net MVC with Servicestack, but that work is still in progress. As most of the people who are using Servicestack can go with the above options since the Razor view engine is now available.

Just try out all options and pick which suits your specific need.

Now, all templates are using 3.71 version of SS. As it is the last version under MIT license. Why am I using that?

People who are starting, or just like to stay with an older version till the product kicks off, can continue with 3.71. And otherwise, it is a wonderful solution that is worth buying.

Do take care while firing up the command of update-package without thinking a bit. If there is a need to use an old version, PLEASE don't update it.

What if someone likes to update from 3.71 to 4.X? There are a couple of breaking changes there. Here are the steps to make it work.

Download the template from the Visual Studio Gallery and install it.

Yes, it will also work with the latest Express version too.

Create a new project and choose any template. Select OK. It is done. Easy enough, right?

Press F5, and it will work with "Hello World" code.

The code may seem a little dirty. It misses comments and a readme. They will be there in future updates.

But the current code is so simple that it should not be too problematic to understand. Obviously, if you know Servicestack or F# a little bit.

Things Needed to Update the Version

  • Fire an update command from NuGet
  • There are chances that you may need to fire it more than once; check package.config that all versions are updated to the same version
  • Remove all the *.cs files and unwanted .htm, .js, .css files for now
  • Now there will be some errors about namespaces; remove unwanted namespaces as code is merged to the base namespace for many files
    • remove ServiceStack.ServiceInterface
    • remove ServiceStack.ServiceHost
    • remove ServiceStack.WebHost.Endpoints
  • Rebuild it and run it.
  • If you get an error about Razor pages, remove the 1.0.0.0 version line from web.config if there is already a 2.0.0.0 one, else change 1.0.0.0 to 2.0.0.0
  • Rebuild and run it.
  • Now if there is an error "Object reference not set to an instance of an object," then we are on the right track.
  • In AppHost.fs file, replace apphost.Init() with apphost.Init() |> ignore This is a breaking change for V4; please do not forget this.
  • Now we need our namespace, so remove "ServiceStackAspNetHost" with your desired project namespace in the entire project, including web.config file.
  • Remove any multiple entries of namespace from the namespace section in web.config file. Keep only one.
  • Rebuild and run it.

It should work. If you're still stuck anywhere, I am also putting up all V4 projects on my GitHub repo; have a look at it.

I have also started a complete series called Functional Web, where I will be putting everything I know about getting started. Not only for SS but for others too.

So, as everyone is putting up APIs for their web application, why should we stay behind?!

Feedback and comments are always welcome.

Frequently Asked Questions

What are the ServiceStack F# templates available in Visual Studio Gallery?

There are four templates available: ServiceStack with ASP.NET host, ServiceStack with ASP.NET host and Razor Engine, ServiceStack with Self host, and ServiceStack with Self host and Razor Engine. Each template option allows developers to choose the hosting and rendering approach that best suits their specific project needs.

Why do these templates use ServiceStack version 3.71?

Version 3.71 is the last version of ServiceStack released under the MIT license. This makes it ideal for developers who are starting out or prefer to use an open-source version before committing to a commercial license for newer versions.

How do I create a new project using the ServiceStack F# templates?

Download the template from the Visual Studio Gallery and install it. Then create a new project and select any of the available templates. Click OK and your project will be ready. You can press F5 to run the default 'Hello World' code immediately.

What should I know before updating from ServiceStack 3.71 to version 4.X?

There are breaking changes between version 3.71 and 4.X, so be cautious when using the NuGet update-package command. If you need to stay on an older version, avoid updating without careful consideration of compatibility issues.

Share this article