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

5

71

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

Careworn answered 27/11, 2014 at 10:33 Comment(0)
A
116

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.

Ache answered 23/1, 2015 at 13:49 Comment(1)
You need to add reference to the HttpListener in the "StartUp Project". So, be carefull if you use WebApp.Start in another project.Detain
M
48

Install the package:

PM> Install-Package Microsoft.Owin.Host.HttpListener
Midyear answered 2/6, 2015 at 18:24 Comment(1)
Note that, for the copy-pasters, you shouldn't be using IncludePrerelease unless you WANT untested code in your app.Broek
T
13

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)

Tetter answered 9/7, 2018 at 10:1 Comment(0)
L
1

Hello for same error message but in slithly different context that i have encountered:

Due to stupid referencing optimization which is totally immature regarding reflection. It happens that MsBuild do not copies the Microsoft.Owin.Host.HttpListener.dll in your startup project if it references another project which uses Owin.

In my case I have the error messsage mentioned above and opted for explicit reference in project using Owin by adding explicit use of the problematic dll so that msbuild sees a reference needed so Microsoft.Owin.Host.HttpListener.dll will be copied (not needed for other dll) -This issue come from the fact that owin stuff does reflection inside itself leaving msbuild completely dummy by removing this dll-:

using Microsoft.Owin.Host.HttpListener;
...
    _log.Debug("Loading type: "+ typeof(OwinHttpListener) + "..."); // Hack to force copy of Microsoft.Owin.Host.HttpListener.dll on target referencing project
Lineman answered 11/10, 2022 at 12:32 Comment(0)
K
-1

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.

Kho answered 28/10, 2020 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.