问题
Is it possible to add an ASP.NET 5 Web Application as a reference to a traditional .NET 4.5 project (Windows Service or Console App) and start it in-process?
Ideally within one solution, so that ASP.NET application and host service can share references to other projects in the same solution.
Tried so far:
dnu publish
produces packages, but attempting to add them produces following error: Install-Package : Could not install package 'WebApplication1 1.0.0'. You are trying to install this package into a project that targets '.NETFramework, Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. When changing framework dnx451
to net451
, Web Application doesn't compile because of missing ASP references.
dnu build
produces binaries, but how to run the application? (where to get IApplicationBuilder and IHostingEnvironment instances?)
回答1:
Nope. It is not possible to run an ASP.NET 5 application without DNX.
But you can run an ASP.NET 5 application without IIS. It can be self-hosted.
来源:https://stackoverflow.com/questions/31101139/self-hosting-asp-net-5-within-net-4-5-application-without-dnx-and-iis