Skip to content

StructureMap.Building.StructureMapBuildException: Error while building type Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver #12

@marefr

Description

@marefr

Using .net core 1.0 and configuration according to readme and the default Web API controller (ValuesController) using attribute routing.

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HKTKRBHJPM10": An unhandled exception was thrown by the application.
StructureMap.Building.StructureMapBuildException: Error while building type Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver.  See the inner exception for details
1.) new DefaultInlineConstraintResolver(*Default of IOptions<RouteOptions>*)
2.) Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver
3.) Instance of Microsoft.AspNetCore.Routing.IInlineConstraintResolver (Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver)
4.) new TreeRouteBuilder(*Default of ILoggerFactory*, *Default of UrlEncoder*, *Default of ObjectPool<UriBuildingContext>*, *Default of IInlineConstraintResolver*)
5.) Microsoft.AspNetCore.Routing.Tree.TreeRouteBuilder
6.) Instance of Microsoft.AspNetCore.Routing.Tree.TreeRouteBuilder
7.) Container.GetInstance(Microsoft.AspNetCore.Routing.Tree.TreeRouteBuilder)
 ---> System.ArgumentException: An item with the same key has already been added. Key: exists
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.Extensions.Options.OptionsCache`1.CreateOptions()
   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   at Microsoft.Extensions.Options.OptionsCache`1.get_Value()
   at Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver..ctor(IOptions`1 routeOptions)
   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\a395dbde6b793293\src\StructureMap.Shared\Building\BuildPlan.cs:line 152
   at StructureMap.BuildSession.BuildUnique(Type pluginType, Instance instance) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\BuildSession.cs:line 120
   at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\SessionCache.cs:line 68
   at StructureMap.Container.GetInstance(Type pluginType) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\Container.cs:line 721
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.GetTreeRouter()
   at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.RouteAsync(RouteContext context)
   at Microsoft.AspNetCore.Routing.RouteCollection.<RouteAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions