Code Monkey home page Code Monkey logo

nancy.bootstrappers.structuremap's People

Contributors

asbjornu avatar cemremengu avatar davidalpert avatar gregsochanik avatar grumpydev avatar horsdal avatar jchannon avatar jvandertil avatar khellang avatar smartcaveman avatar sphiecoh avatar thecodejunkie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nancy.bootstrappers.structuremap's Issues

Server error when changing from nancy 0.9 to 0.10

hi, we just migrated from 0.9 to 0.10 and we have a server error looking like this:

StructureMap Exception Code: 205
Missing requested Instance property "modulePath" for InstanceKey "Nancy.Testing.Fakes.FakeNancyModule"

On version 0.9 we fixed it by setting this:

       container.Configure(x =>
        {
            x.SelectConstructor(() => new FakeNancyModule()); //Structuremap container fix
        });

On version 0.10 we don't know how to fix it, and why is that line needed in version 0.9

ComponentRegistrationException for IRequestStartup class

There's a problem with how IRequestStartup classes are handled in Windsor Bootstrapper.

When WindsorNancyBootstrapper.RegisterAndGetRequestStartupTasks is called for the first time all is good. IRequestStartups are registered scoped to single request and then resolved.

However any further call to that method during subsequent requests fails with message "There is already a component with that name.".

I understand this can work like that in bootstrappers that create child containers, but given that with Windsor it's not implemented like that, there should be a guard of sorts.

Something is wrong and I have no idea what!

This is an enhancement to docs. Having installed the latest NuGet packages for Nancy and StructureMapNancyBootstrapper, I've had a horrific day trying to get something basic working inside an existing project I could simply have used WebAPI for (specifically, being fairly new to Nancy and it's bootstrapper, I just want a tutorial showing a non-self-hosted setup using the StructureMap Bootstrapper, using an appropriate VS2013 template, for RESTful API endpoints - But I suspect such noobie issues are for SO not here, since nobody has blogged an end-to end with that specific scenario :)

What I'd really like is an end-to-end walk through for non-happy path stuff, since small scale, super-duper-happy-path stuff trades-off against the pain of working with existing legacy code (which is often far from a happy experience and there is naturally so much more of it, so I could argue that's the real 'happy path'). Indeed, copying and pasting the sample from the README.md into VS and I get the attached image indicating that no ApplicationStartup etc. methods exist to override. Has the boot-strapper not got these methods any more? Or perhaps I'm using the wrong IContainer?

So, after that rant, would it be too much to ask to include the using statements as part of the sample?

Thanks
nancyproblem

NuGet package Id comes through with incorrect case

In packages.config;

<package id="Nancy.Bootstrappers.StructureMap" version="0.20.0" targetFramework="net45" />

Project reference is lowercase as per nuspec id;

<HintPath>..\packages\Nancy.Bootstrappers.StructureMap.0.20.0\lib\net40\Nancy.Bootstrappers.StructureMap.dll</HintPath>

BUT the physical directory is not;

image

Which means the build fails on (case-sensitive) Mono.

To fix this you usually need to ask the wonderful @jeffhandley to do some voodoo on the nuget server (e.g. Particular/NServiceBus#1271).

NuGet issue on MonoDevelop/Xamarin Studio (package not found)

Since Unix is actually case sensitive on the folder name it expects the package in the folder "Nancy.Bootstrappers.StructureMap" but since the nupkg file is named "Nancy.BootStrappers.StructureMap" it extracts the package to the directory with upper case "S" in BootStrappers which causes this problem. This is a naming error in the first place and should be fixed at least with the next version! All other Bootstrapper plugins are fine, just this one is not compatible on any platform with case sensitive folder and filenames

No suitable methods found to override

after upgrade to 0.22.2 the virtual methods described in the read me-file does not exist (ConfigureApplicationContainer, ConfigureRequestContainer, RequestStartup and GetApplicationContainer)? Please update the read me file? Or am I missing something?

IRequestStartup not being registered during RegisterAndGetRequestStartupTasks

Hi everyone, please excuse complete ignorance on how to properly use Github/report issues, and I don't feel confident that my code is good enough to do a pull request (if I could figure out how!!)

Anyway, I upgraded from 0.23 to 1.1 and my external Module, that implemented IRequestStartup wasn't being called anymore.

My code change to fix was:
In this RegisterAndGetRequestStartupTasks function, it appeared like the types weren't actually being registered, so I added:

container.Configure(registry => {
foreach (var requestStartupType in requestStartupTypes) {
registry.For(typeof(IRequestStartup)).LifecycleIs(Lifecycles.Unique).Use(requestStartupType);
}
});

Thanks for being patient with the bad way to get issues reported/code fixes in,
Stephen

Could not load type 'StructureMap.Configuration.DSL.Registry'

Structuremap 4.1.0.318
Nancy 1.4.3

using (var host = new NancyHost(uri, new Bootstrapper(), hostConfigs))

Could not load type 'StructureMap.Configuration.DSL.Registry' from assembly 'StructureMap, Version=4.0.1.318, Culture=neutral, PublicKeyToken=null'.

at Nancy.Bootstrappers.StructureMap.StructureMapNancyBootstrapper.b__0(ConfigurationExpression registry)
at StructureMap.PipelineGraph.Configure(Action1 configure) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\PipelineGraph.cs:line 170 at StructureMap.Container.Configure(Action1 configure) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\Container.cs:line 806
at Nancy.Bootstrappers.StructureMap.StructureMapNancyBootstrapper.RegisterBootstrapperTypes(IContainer applicationContainer)
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 Api.Push.ManagementInterface.Nancy.EntryPoint.Main(String[] args) in C:\Projects\api-push\src\Api.Push\ManagementInterface\Api.Push.ManagementInterface.Nancy\EntryPoint.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

StructureMapBootstrapper doesn't seem to add default types correctly

A clean install of Nancy, Nancy-aspnet, Nancy-razor and Nancy-structuremap seems to have a problem with adding the DefaultRazorConfiguration to the container. On app start-up, you're presented with the following error:

StructureMap Exception Code: 202
No Default Instance defined for PluginFamily Nancy.ViewEngines.Razor.IRazorConfiguration, Nancy.ViewEngines.Razor, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null

I've uploaded a sample solution to http://www.rasmuskl.dk/NancySMTest.zip

Experiencing intermittent NullReferenceExceptions under heavy(ish) load with v0.23

After upgrading to v0.23 of the StructureMap Bootstrapper we've begun to notice an issue when making concurrent requests to NancyFx powered services.

Every now and then NullReferenceExceptions occur when the service tries to resolve the requested INancyModule from the StructureMap container. The issue does not occur in v0.22.2.

Example stack trace

StructureMap.Building.StructureMapBuildException: Error while building type Modules.StatusEndpoint.StatusModule.  See the inner exception for details
1.) new StatusModule(Enumerable of Modules.StatusEndpoint.IStatusReporter with all registered instances)
2.) Modules.StatusEndpoint.StatusModule
3.) Instance of Nancy.INancyModule (Modules.StatusEndpoint.StatusModule)
4.) Container.GetInstance(Nancy.INancyModule)
5.) Container.TryGetInstance(Nancy.INancyModule)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at StructureMap.BuildSession.BuildNewInSession(Type pluginType, Instance instance) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\BuildSession.cs:line 107
   at StructureMap.Pipeline.LifecycleObjectCache.Get(Type pluginType, Instance instance, IBuildSession session) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Pipeline\LifecycleObjectCache.cs:line 60
   at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\SessionCache.cs:line 88
   at StructureMap.BuildSession.<GetAllInstances>b__3[T](Instance x) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\BuildSession.cs:line 121
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at StructureMap.BuildSession.GetAllInstances[T]() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\BuildSession.cs:line 119
   at lambda_method(Closure , IBuildSession , IContext )
   --- End of inner exception stack trace ---
   at lambda_method(Closure , IBuildSession , IContext )
   at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Building\BuildPlan.cs:line 153
   at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\SessionCache.cs:line 68
   at StructureMap.Container.GetInstance(Type pluginType) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Container.cs:line 325
   at StructureMap.Container.TryGetInstance(Type pluginType) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Container.cs:line 268
   at StructureMap.Container.TryGetInstance[T]() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Container.cs:line 277
   at Nancy.Routing.DefaultRouteResolver.BuildResult(NancyContext context, MatchResult result)
   at Modules.NewRelicStartup.<Initialize>b__0(NancyContext context) in c:\BuildAgent\work\fc461108b638e316\src\Modules\NewRelicStartup.cs:line 21
   at Nancy.BeforePipeline.<>c__DisplayClass4.<Wrap>b__3(NancyContext ctx, CancellationToken ct)

As the error is being thrown from within StructureMap, it could be a problem within v3.0.1.114. So I will add an issue there too.

We've experience it across 2 separate applications, so were wondering if anyone else had seen it too.

Nancy Self Hosted application crashes with StackOverflowException on exit

I've created an example project here: https://github.com/jvandertil/NancyStructureMapSelfHostBug

Steps to reproduce:

  1. Start application
  2. Press Enter in the console application
  3. Application is force closed by a StackOverflowException

Removing the custom bootstrapper makes the StackOverflowException go away. However the custom bootstrapper is simply this:

    public class Bootstrapper : StructureMapNancyBootstrapper
    {
    }

I'll investigate for a bit, but I am not sure if I can find anything useful.

Obviously, it happens when the container is disposed. So that narrows it down a bit :)

applicationContainer.Configure(registry => registry.For<INancyModuleCatalog>().Singleton().Use(this));

This raised a mental red flag for me, as it might cause recursive disposal.

SM3 update broke the bootstrapper

Appears it may be a SM3 bug.

Running the test Should_be_able_to_resolve_engine():

  • Runs through this line, which registers IFoo
    • Confirmed at this point that IFoo can be resolved by the container using GetInstance
  • Eventually hits this line
    • Confirmed at this point (via the immediate window) that the instance of the container is the same as above, and IFoo can still be resolved from it using GetInstance
  • Tracing over that line blows up with the following:
StructureMap.StructureMapConfigurationException
No default Instance is registered and cannot be automatically determined for type 'Nancy.Tests.Fakes.IFoo'

There is no configuration specified for Nancy.Tests.Fakes.IFoo

1.) new Dependency(*Default of IFoo*)
2.) Nancy.Tests.Fakes.Dependency
3.) Instance of Nancy.Tests.Fakes.IDependency (Nancy.Tests.Fakes.Dependency)
4.) new FakeNancyModuleWithDependency(*Default of IDependency*, *Default of IFoo*)
5.) Nancy.Tests.Fakes.FakeNancyModuleWithDependency
6.) Instance of Nancy.INancyModule (Nancy.Tests.Fakes.FakeNancyModuleWithDependency)
7.) Container.GetAllInstances<Nancy.INancyModule>()
8.) new RouteCache(*Default of INancyModuleCatalog*, *Default of INancyContextFactory*, *Default of IRouteSegmentExtractor*, *Default of IRouteDescriptionProvider*, *Default of ICultureService*, Enumerable of Nancy.Routing.IRouteMetadataProvider with all registered instances)
9.) Nancy.Routing.RouteCache
10.) Instance of Nancy.Routing.IRouteCache (Nancy.Routing.RouteCache)
11.) new DefaultRouteResolver(*Default of INancyModuleCatalog*, *Default of INancyModuleBuilder*, *Default of IRouteCache*, *Default of IRouteResolverTrie*)
12.) Nancy.Routing.DefaultRouteResolver
13.) Instance of Nancy.Routing.IRouteResolver (Nancy.Routing.DefaultRouteResolver)
14.) new DefaultRequestDispatcher(*Default of IRouteResolver*, Enumerable of Nancy.Responses.Negotiation.IResponseProcessor with all registered instances, *Default of IRouteInvoker*)
15.) Nancy.Routing.DefaultRequestDispatcher
16.) Instance of Nancy.Routing.IRequestDispatcher (Nancy.Routing.DefaultRequestDispatcher)
17.) new NancyEngine(*Default of IRequestDispatcher*, *Default of INancyContextFactory*, Enumerable of Nancy.ErrorHandling.IStatusCodeHandler with all registered instances, *Default of IRequestTracing*, *Default of DiagnosticsConfiguration*, *Default of IStaticContentProvider*)
18.) Nancy.NancyEngine
19.) Instance of Nancy.INancyEngine (Nancy.NancyEngine)
20.) Container.GetInstance(Nancy.INancyEngine)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.