OWIN HttpListener not located

C#Exception.Net 4.5Owinasp.net Web-Api2

C# Problem Overview


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)

C# Solutions


Solution 1 - C#

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.

Solution 2 - C#

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

To install package, use this command line :

Install-Package Microsoft.Owin.Host.HttpListener

Solution 3 - C#

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.

Solution 4 - C#

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

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
QuestionGilliVillaView Question on Stackoverflow
Solution 1 - C#Pierre ArnaudView Answer on Stackoverflow
Solution 2 - C#Damith AsankaView Answer on Stackoverflow
Solution 3 - C#Daniel ParkView Answer on Stackoverflow
Solution 4 - C#BaidalyView Answer on Stackoverflow