I've created a new class library project with the following startup class:
public class Startup
{
public void Configure(IAppBuilder app)
{
app.Run(ctx =>
{
ctx.Response.StatusCode = 200;
ctx.Response.ContentType = "text/plain";
return ctx.Response.WriteAsync("Hello from Owin");
});
}
}
I have the following packages installed:
<packages>
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.HttpListener" version="2.1.0" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="OwinHost" version="2.1.0" targetFramework="net45" />
</packages>
When I attempt to run owinhost.exe
from /bin/debug
I get the following error:
Error: System.EntryPointNotFoundException
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class.
Do I need to do anything else to get OwinHost.exe to work with a class library project (I had the same issue with a Console application).
If you execute the OwinHost.exe without parameters, the method name needs to be Configuration
, not Configure
.
Also, execute owinhost.exe
under the root path (A.K.A {projectDir}) and output the builds to /bin, not /bin/debug. Of course, these are configurable through switches to OwinHost.exe
but this is what it needs if you wanna run it w/o any switches.
More in depth explanation is available here: OWIN Startup Class Detection and here: Good Old F5 Experience With OwinHost.exe on Visual Studio 2013