I am attempting to self-host OWIN in a windows service. When I debug through visual studio 2017 it works great, but when I try to run the service in a release build I get the following error.
Unhandled Exception: System.EntryPointNotFoundException: The following errors occurred while attempting to load the app. - No 'Configuration' method was found in class '., Vps.SysComm.Service, Version=3.12.0.0, Culture=neutral, PublicKeyToken=null'. at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp(StartContext context) at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options) at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options) at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options) at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options) at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options) at ..() at ..(String[] )
What is interesting is the . for startup class name.
This is my startup class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(Vps.SysComm.Service.Startup))]
namespace Vps.SysComm.Service
{
public class Startup
{
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
public void Configuration(IAppBuilder appBuilder)
{
// Configure Web API for self-host.
HttpConfiguration config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
appBuilder.UseWebApi(config);
}
}
}
inside my Main service start method
string baseAddress = "http://localhost:9000";
_sysCommAPI = WebApp.Start<Startup>(url: baseAddress);
You can try Thread.Sleep(100); inside Configuration method. Hope It will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.