EntryPointNotFoundException при самостоятельном размещении WebAPI с использованием OWIN

Я пытаюсь продать свой веб-API с помощью OWIN, перейдя по ссылке ниже

http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

Но, Durign выполнение этой строки ниже

using (WebApp.Start<SelfHostStartup>(url: baseAddress)).

Я получаю EntryPointNotFoundException, так как MyNamespace.SelfHostStartup не найден в сборке.

любая помощь будет оценена.

Спасибо.

public class SelfHostStartup
    {
        // 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. 
            var config = new HttpConfiguration();

            // Loads external library's (that contain the web api controllers) into the web api self host system
            var assemblyResolver = new SelfHostAssemblyResolver();
            config.Services.Replace(typeof(IAssembliesResolver), assemblyResolver);

            // Creates the IoC Container & mounts to Web API
            config.DependencyResolver =
                new AutofacWebApiDependencyResolver(Framework.Infastructure.Dependency.AutofacContainer.Container);

            config.Services.Add(typeof(IExceptionLogger), new MyNamespace.ApiExceptionLogger(Framework.Infastructure.Dependency.AutofacContainer.Resolve<ILogger>()));
            // Configures Web API Controller Routing
            RouteConfig(config);

            config.EnsureInitialized();
            // Tells OWIN self host to use this configuration
            appBuilder.UseWebApi(config);
        }

        /// <summary>
        /// Configuration of the Routing for the Web API Controllers
        /// </summary>
        /// <param name="config"></param>
        private void RouteConfig(HttpConfiguration config)
        {
#if DEBUG
            //Enabling Cors Globally
            config.EnableCors(new EnableCorsAttribute("http://localhost:60279", "*", "*"));
#else
            config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
#endif
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "Core",
                routeTemplate: "api/core/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            config.Routes.MapHttpRoute(
                name: "Domain",
                routeTemplate: "api/domain/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            config.Routes.MapHttpRoute(
               name: "Domain1",
               routeTemplate: "api/domain/{controller}/{action}/{id}",
               defaults: new { id = RouteParameter.Optional }
               );

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
    }

0 ответов

Другие вопросы по тегам