72

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)
3
  • Is Microsoft.Owin.Host.HttpListener.dll deployed with your app, next to the main assembly? Alternatively you can add it as a reference to this project and have it copied to the bin directory.
    – Marcel N.
    Aug 1, 2014 at 23:46
  • @MarcelN. Yes. It is already added as a reference to the project.
    – GilliVilla
    Aug 2, 2014 at 17:28
  • 1
    Similar issue: katanaproject.codeplex.com/discussions/449301 Aug 7, 2014 at 14:01

4 Answers 4

131

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.

4
  • 3
    Thanks Pierre. A suggestion for improvement to your answer: I do not want to have to manually add that reference to all applications that will use my library. Instead I simply reference something (anything) inside the HttpListener assembly from my own assembly, so that the build is forced to bring along that DLL to the application's output folder. Dec 1, 2015 at 11:06
  • Good point; indeed, you just have to make sure the Microsoft.Owin.Host.HttpListener.dll gets included. However that's done is up to you :-) Dec 2, 2015 at 12:09
  • 8
    why is this not a dependency of Microsoft.Owin.Hosting ? Jul 25, 2016 at 20:35
  • You need to set bold make sure that the executable consuming the library also includes the reference
    – qakmak
    Feb 22, 2020 at 10:41
47

Make sure you have install package Microsoft.Owin.Host.HttpListener

To install package, use this command line :

Install-Package Microsoft.Owin.Host.HttpListener
2
  • I had a reference to this dll but for some reason it was not copied to the bin-Directory. I then tried your Suggestion to Install it via Nuget and it worked. Now it's copied to the Output-directory Oct 3, 2015 at 10:13
  • You need to add reference to the HttpListener in the "StartUp Project". So, be carefull if you use WebApp.Start in another project.
    – Johann67
    Dec 3, 2018 at 13:55
7

Sometimes NuGet references are added in an incomplete state. If you have the packages installed, however references are not included, try reinstalling them via;

Update-Package -reinstall

in the package manager console.

2
  • I also tried to use Update-Package -reinstall but in the middle of the process there was an error and all packages havee been deleted. I manually had to add all references again...so be careful ;) Oct 3, 2015 at 10:09
  • Simply restore packages.config from source control, or make sure you backup beforehand Apr 2, 2017 at 22:50
0

Small addition to Pierre's and Damith's answer. If you are using Mac OS, run the following command to install HttpListener:

dnu install Microsoft.Owin.Host.HttpListener

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.