0

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).

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Ben Foster
  • 34,340
  • 40
  • 176
  • 285

1 Answers1

2

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

tugberk
  • 57,477
  • 67
  • 243
  • 335
  • This was a typo on my behalf. Even after renaming to `Configuration` I get the same error. – Ben Foster Feb 25 '14 at 23:12
  • 1
    The thing that was tripping me up was that I was building to /bin/debug. I attempted to use the `-d` switch to specify my build directory but [looking at the source](https://katanaproject.codeplex.com/SourceControl/latest#src/OwinHost/Program.cs) this doesn't appear to do anything. – Ben Foster Feb 26 '14 at 09:58