题
我使用以下启动类创建了一个新的类库项目:
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");
});
}
}
我安装了以下软件包:
<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>
当我尝试跑步时 owinhost.exe
从 /bin/debug
我收到以下错误:
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.
我是否需要执行其他操作才能让 OwinHost.exe 处理类库项目(我在控制台应用程序中遇到了同样的问题)。
解决方案
如果不带参数执行 OwinHost.exe,则方法名称需要为 Configuration
, , 不是 Configure
.
另外,执行 owinhost.exe
在根路径(又名 {projectDir})下并将构建输出到 /bin,而不是 /bin/debug。当然,这些都可以通过开关进行配置 OwinHost.exe
但这就是如果你想在没有任何开关的情况下运行它所需要的。
更深入的解释可以在这里找到: OWIN 启动类检测 和这里: Visual Studio 2013 上 OwinHost.exe 的良好旧 F5 体验
不隶属于 StackOverflow