오윈호스트클래스 라이브러리 프로젝트를 위해 작동하지 않음
문제
다음 시작 클래스로 새 클래스 라이브러리 프로젝트를 만들었습니다:
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.
나는 호스트를 얻기 위해 다른 일을 할 필요가 있습니까?클래스 라이브러리 프로젝트(콘솔 응용 프로그램과 동일한 문제가 있음)로 작업 할 수 있습니다.
해결책
당신이 호스트를 실행하는 경우.매개 변수가 없으면 메서드 이름이 있어야 합니다 Configuration
,아니 Configure
.
또한 실행 owinhost.exe
루트 경로(예:{프로젝트 디렉터리})아래에서 빌드를/빈/디버그가 아닌/빈/디버그로 출력합니다.물론,이들은 스위치를 통해 구성 할 수 있습니다 OwinHost.exe
그러나 이것은 당신이 어떤 스위치 없이 그것을 실행하고 싶다면 필요한 것입니다.
더 깊이 있는 설명은 여기에서 확인할 수 있습니다: 오윈 스타트업 클래스 탐지 그리고 여기: 오윈호스트와 함께 좋은 오래된 경험.엑스 온 비주얼 스튜디오 2013
제휴하지 않습니다 StackOverflow