Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

owin

signalr

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

like image 496
jignesh Avatar asked Nov 27 '14 10:11

jignesh


4 Answers

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.

like image 93
skoz Avatar answered Nov 20 '22 11:11

skoz


Install the package:

PM> Install-Package Microsoft.Owin.Host.HttpListener
like image 33
sedatiko Avatar answered Nov 20 '22 10:11

sedatiko


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)

like image 12
Owen Pauling Avatar answered Nov 20 '22 10:11

Owen Pauling


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
like image 1
Thierry Brémard Avatar answered Nov 20 '22 11:11

Thierry Brémard