OWIN HttpListener not located

GilliVilla picture GilliVilla · Aug 2, 2014 · Viewed 31.6k times · Source

When I try to start :

WebApp.Start<SrvcHst>(new StartOptions { Port = 9956, 
     ServerFactory = "Microsoft.Owin.Host.HttpListener" });

I get the following exception. What could be the root cause?

System.MissingMemberException was caught
  HResult=-2146233070
  Message=The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener
  Source=Microsoft.Owin.Hosting
  StackTrace:
       at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveServerFactory(StartContext context)
       at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
       at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options)
       at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
       at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options)
       at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options)
       at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options)

Answer

Pierre Arnaud picture Pierre Arnaud · Nov 13, 2014

You have to include Microsoft.Owin.Host.HttpListener.dll in your project references.

You can add it through NuGet.

However, if the code executing:

WebApp.Start<SrvcHst> (...);

is contained within a class library, make sure that the executable consuming the library also includes the reference to Microsoft.Owin.Host.HttpListener.dll, or else it would not get deployed with your program, as there are no explicit references to it from the class library.

Have a look at your bin/Debug folder and make sure the DLL is there.