none
windows service and HttpSelfHostServer RRS feed

  • Question

  • I created a service and tried to run it with the next code :

     protected override void OnStart(string[] args)
            {
                var httpSelfHostConfiguration = new HttpSelfHostConfiguration("http://localhost:1234");
                httpSelfHostConfiguration.Routes.MapHttpRoute(
                    name:"Prepaid",
                    routeTemplate:"prepaid/{id}",
                    defaults:new {id=RouteParameter.Optional});
               // httpSelfHostServer = new HttpSelfHostServer(httpSelfHostConfiguration, new ProcessRequest());
               // var task = httpSelfHostServer.OpenAsync();
               //task.Wait();
    }

    i try to run the service and before i reach this code i get error

    System.TypeLoadException: 'Inheritance security rules violated by type: 'System.Web.Http.SelfHost.HttpSelfHostConfiguration'. Derived types must either match the security accessibility of the base type or be less accessible.'
    

    what can cause this?

    Tuesday, July 16, 2019 6:24 PM

Answers

  • Hello,

    See the recommended solution in this post by dluxfordhpf reply

    https://github.com/dotnet/corefx/issues/11100


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by want 2 Learn Wednesday, July 17, 2019 7:02 AM
    Tuesday, July 16, 2019 9:39 PM
    Moderator