How to invoke HybridHttpOrThreadLocalScoped in StructureMap 3

985 Views Asked by At

I am trying to move from Structuremap 2.6.4.1 to 3.1.4.143 but am unable to figure out how to handle HybridHttpOrThreadLocalScoped. None of the SO Q/A I can find seems to work for me...

I have the following code:

using StructureMap;
using StructureMap.Web;

ObjectFactory.Configure( x =>
{
    x.For<IRepository<Person>>()
        .HybridHttpOrThreadLocalScoped() // Need the repo to survive for the duration of the thread!
        .Use<Repository_Stub<Person>>()
        .Ctor<IEnumerable<IEntity>>( "seed" ).Is( persons );
} );

that gives me this error:

'StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression<IRepository<Person>>' 
does not contain a definition for 'HybridHttpOrThreadLocalScoped' and no extension method
'HybridHttpOrThreadLocalScoped' accepting a first argument of type
StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression<IRepository<Person>>'
could be found (are you missing a using directive or an assembly reference?)

Is there a new way to invoke HybridHttpOrThreadLocalScoped?

Thansk in advance!

1

There are 1 best solutions below

0
On

HybridHttpOrThreadLocalScoped has been moved into a separate nuget package called Structuremap.Web.

It can be installed by running Install-Package structuremap.web in your Nuget Package Console. See this post for more information.