Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceStack EndpointHostConfig & WebHost does not exist? C# MVC

Following a tutorial of using ServiceStack, I'm trying to compile the following code:

public class AppHost : AppHostBase
{
    public AppHost() : base("Protein Tracker Web Services", typeof(HelloService).Assembly) { }

    public override void Configure(Funq.Container container)
    {
        SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" });
    }
}

This gives me the following error:

The type or namespace name 'EndpointHostConfig' could not be found (are you missing a using directive or an assembly reference?)

I tried to add the suggested:

using ServiceStack.WebHost.Endpoints;

Gives me the following error:

The type or namespace name 'WebHost' does not exist in the namespace 'ServiceStack' (are you missing an assembly reference?)

like image 260
myslex Avatar asked Dec 06 '13 19:12

myslex


2 Answers

You are probably referencing the v4 ServiceStack framework which has just been released into beta. There has been a lot of refactoring and restructuring of the namespaces and classes which is where the conflict will arise.

These release notes for v4 discuss the significant changes made to ServiceStack from v3 to v4.

The part most relevant to you is:

EndpointHostConfig is now HostConfig and is limited to just Configuration.


A lot of the tutorials are still for v3 which is OpenSource, which is what I suspect you are following.

You should include the version number in your nu-get install. Such as:

PM> Install-Package ServiceStack -Version 3.9.71

This will get you the latest OpenSource version of ServiceStack (3.9.71). Or alternatively see the v4 documentation.

v3 Documentation - Relevant for your tutorials
v4 (Latest - commercial)

Hope this helps.

like image 104
Scott Avatar answered Nov 01 '22 01:11

Scott


For those may be following outdated tutorials/examples, but wish to use the new v4 API:

The ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory used in Web.config's handler mapping has been renamed to just ServiceStack.HttpHandlerFactory

This requires a quick update to our service's Web.config:

<handlers>
  <add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
like image 25
defines Avatar answered Nov 01 '22 01:11

defines