The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener

C#SignalrOwin

C# Problem Overview


I have implemente signalR in window service.

private IDisposable SignalR { get; set; }

public void Configuration(IAppBuilder app)
{   
        var hubconfig=new Microsoft.AspNet.SignalR.HubConfiguration();
        hubconfig.EnableJSONP = true;
                    
        app.UseCors(CorsOptions.AllowAll);
        app.MapSignalR(hubconfig);
}


private void StartSignalRServer(StringBuilder sbLog)
{
        try
        {
            this.SignalR = WebApp.Start(ServerURI); //This throws exception

            //this.SignalR= WebApp.Start<Startup>(ServerURI);
            sbLog.Append(string.Format("{0}--------SignalR Server Started------",Environment.NewLine));
        }
        catch (Exception ex)
        {
            sbLog.Append(string.Format("{0}Exception in StartSignalRServer=>{1}", Environment.NewLine,ex.Message));
        }
}

> Exception:The server factory could not be located for the given input: > Microsoft.Owin.Host.HttpListener

C# Solutions


Solution 1 - C#

The Microsoft.Owin.Host.HttpListener assembly is a runtime reference in WebApp.Start. You need to include it in the project's references for it to be available for loading. Check the bin\Debug (etc) directory to make sure it's included. May as well add it as a nuget dependency as well.

Solution 2 - C#

Install the package:

PM> Install-Package Microsoft.Owin.Host.HttpListener

Solution 3 - C#

Install the Microsoft.Owin.Host.HttpListener package from Nuget using:

PM> Install-Package Microsoft.Owin.Host.HttpListener

(unlike an earlier answer you should avoid using -IncludePrerelease in production code)

Solution 4 - C#

I encountered same error.

In project A -- I am starting owin web service using WebApp.Start() in a function. In Project B -- I am calling project A's function here. Unfortunately Project B is not my .Net solution's startup project. Project C is my .Net Solution startup project.

If I Install nuget package using command Install-Package Microsoft.Owin.Host.HttpListener in solution's start up project i.e Project, C it works fine. If I do the same in Project B it does not work. So be careful while installing nuget package.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjigneshView Question on Stackoverflow
Solution 1 - C#skozView Answer on Stackoverflow
Solution 2 - C#sedatikoView Answer on Stackoverflow
Solution 3 - C#Owen PaulingView Answer on Stackoverflow
Solution 4 - C#Rajesh KumarView Answer on Stackoverflow