Wenn ich versuche zu beginnen:
WebApp.Start<SrvcHst>(new StartOptions { Port = 9956,
ServerFactory = "Microsoft.Owin.Host.HttpListener" });
Ich bekomme die folgende Ausnahme. Was könnte die Ursache sein?
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)
Sie müssen Microsoft.Owin.Host.HttpListener.dll
in Ihre Projektverweise einfügen.
Sie können es über NuGet hinzufügen.
Wenn jedoch der Code ausgeführt wird:
WebApp.Start<SrvcHst> (...);
in einer class-Bibliothek enthalten ist, stellen Sie sicher, dass die executable, die die Bibliothek verwendet, auch den Verweis auf Microsoft.Owin.Host.HttpListener.dll
enthält. Andernfalls wird sie nicht mit Ihrem Programm bereitgestellt, da keine expliziten Verweise darauf vorhanden sind die Klassenbibliothek.
Sehen Sie sich Ihren bin/Debug
-Ordner an und stellen Sie sicher, dass die DLL vorhanden ist.
Stellen Sie sicher, dass Sie das Installationspaket Microsoft.Owin.Host.HttpListener
installiert haben.
Verwenden Sie zur Installation des Pakets diese Befehlszeile:
Install-Package Microsoft.Owin.Host.HttpListener
Manchmal werden NuGet-Referenzen unvollständig hinzugefügt. Wenn Sie die Pakete installiert haben, jedoch keine Referenzen enthalten sind, installieren Sie sie erneut über;
Update-Package -reinstall
in der Paket-Manager-Konsole.
Kleine Ergänzung zu Pierre und Damiths Antwort. Wenn Sie Mac OS verwenden, führen Sie den folgenden Befehl aus, um HttpListener zu installieren:
dnu install Microsoft.Owin.Host.HttpListener