nancy selfhost, with dryioc and bootstrapper -> Method not found exception

1

At work we require a small application, and decided to test some things we are not really familiar with for this project as well.

I started with a console app, using topshelf to host nancy via the nancy selfhosting package. All of this works.

Now I wanted to wire in the DryIoc container into the nancy bootstrapper and got the following error:

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'DryIoc.Rules DryIoc.Rules.With(DryIoc.FactoryMethodSelector, DryIoc.ParameterSelector, DryIoc.PropertiesAndFieldsSelector, Boolean)'.
  Source=Nancy.Bootstrappers.DryIoc
  StackTrace:
   at Nancy.Bootstrappers.DryIoc.DryIocNancyBootstrapper.<GetApplicationContainer>b__0(Rules rules)
   at DryIoc.Container..ctor(Func`2 configure, IScopeContext scopeContext)
   at Nancy.Bootstrappers.DryIoc.DryIocNancyBootstrapper.GetApplicationContainer()
   at Nancy.Bootstrapper.NancyBootstrapperBase`1.Initialise()
   at Nancy.Hosting.Self.NancyHost..ctor(INancyBootstrapper bootstrapper, HostConfiguration configuration, Uri[] baseUris)
   at Nancy.Hosting.Self.NancyHost..ctor(Uri baseUri, INancyBootstrapper bootstrapper, HostConfiguration configuration)
   at Segrey.Licensing.Web.WebService.Start() in I:\git projects\Segrey.Licensing\Segrey.Licensing.Web\WebService.cs:line 21
   at Segrey.Licensing.Service.Program.<>c.<CreateHost>b__1_2(WebService ls) in I:\git projects\Segrey.Licensing\Segrey.Licensing.Service\Program.cs:line 26
   at Topshelf.ServiceConfiguratorExtensions.<>c__DisplayClass2_0`1.<WhenStarted>b__0(T service, HostControl control)
   at Topshelf.Builders.DelegateServiceBuilder`1.DelegateServiceHandle.Start(HostControl hostControl)
   at Topshelf.Hosts.ConsoleRunHost.Run()

My bootstrapper: empty, no registrations yet as I first wanted to test this out before making it more complex

public class Bootstrapper : DryIocNancyBootstrapper
{
    protected override void ApplicationStartup(IContainer container, IPipelines pipelines)
    {
        //No registrations should be performed in here, however you may
        //resolve things that are needed during application startup.
        base.ApplicationStartup(container, pipelines);
    }

    protected override void ConfigureApplicationContainer(IContainer container)
    {
        //Perform registation that should have an application lifetime
        base.ConfigureApplicationContainer(container);
    }

    protected override void ConfigureRequestContainer(IContainer container, NancyContext context)
    {
        //Perform registrations that should have a request lifetime
        base.ConfigureRequestContainer(container, context);
    }

    protected override void RequestStartup(IContainer container, IPipelines pipelines, NancyContext context)
    {
        // No registrations should be performed in here, however you may
        // resolve things that are needed during request startup.
        base.RequestStartup(container, pipelines, context);
    }
}

And in my .Start method for the service via topshelf where the bootstrapper gets assigned

public void Start()
{
    var hostConfig = new HostConfiguration() { UrlReservations = new 
    UrlReservations { CreateAutomatically = true } };
    var uri = new Uri(_hostUrl);
    _nancyHost = new NancyHost(uri, new Bootstrapper(), hostConfig);
    _nancyHost.Start();
}

Error occurs on new NancyHost(uri, new Bootstrapper(), hostConfig); as soon as I add new Bootstrapper() into the arguments

nancy
topshelf
dryioc
asked on Stack Overflow Jan 4, 2018 by Hairydruidy

1 Answer

1

Sounds like a versioning issue. Check your .config file for binding redirects for dryioc.

It appears DryIocNancyBootstrapper thinks it's using version X of DryIOC, but instead it's using version Y (due to a binding redirect), which doesn't have that method (either it was removed or it's an older version that doesn't yet have it).

Figure out what version DryIocNancyBootstrapper wants (i.e., version X in the example above) and reference that version.

answered on Stack Overflow Jan 4, 2018 by (unknown user)

User contributions licensed under CC BY-SA 3.0