signed version of structuemap 4.5.3 in webapi 2.0 project. compile error -'CreatePluginFamilyExpr

30 views
Skip to first unread message

stev...@mail.com

unread,
Dec 8, 2017, 12:36:30 PM12/8/17
to structuremap-users

I am using a signed version of structuemap 4.5.3 in a webapi 2.0 project.

I am getting the following compile error on the following piece of code.

For<ISpaceRadarDbContext>()

                        .HttpContextScoped()

                        .Use(c => new SpaceRadarDbContext());

The error below saids something 'CreatePluginFamilyExpression<>' is defined in an assembly that is not referenced 

How do Fix this?



using SpaceRadar.Context;

using SpaceRadar.Repositories;

using SpaceWeather.Log;

using StructureMap;

using StructureMap.Web;


namespace SpaceRadar.Web.Api.DependencyResolution

{

    public class LogRegistry : Registry

    {

        public LogRegistry()

        {

            For<ISpaceWeatherLogService>().AlwaysUnique().Use(s => s.ParentType == null ? new SpaceWeatherLogService(s.GetType()) : new SpaceWeatherLogService(s.ParentType));

            For<ISpaceRadarDbContext>()

                        .HttpContextScoped()

                        .Use(c => new SpaceRadarDbContext());


        }

    }

Severity          Code    Description     Project File      Line     Suppression State

Error   CS0012           The type 'CreatePluginFamilyExpression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'StructureMap, Version=4.0.0.315, Culture=neutral, PublicKeyToken=null'.            SpaceRadar.Web.Api C:\spaceradarweb\spaceradarweb\SpaceRadar\SpaceRadar\src\SpaceRadar.Web.Api\DependencyResolution\LogRegistry.cs            14        Active

Error   CS0012           The type 'GenericFamilyExpression' is defined in an assembly that is not referenced. You must add a reference to assembly 'StructureMap, Version=4.0.0.315, Culture=neutral, PublicKeyToken=null'.            SpaceRadar.Web.Api C:\spaceradarweb\spaceradarweb\SpaceRadar\SpaceRadar\src\SpaceRadar.Web.Api\DependencyResolution\LogRegistry.cs            14        Active

 

Untitled.png

Jeremy Miller

unread,
Dec 8, 2017, 1:37:54 PM12/8/17
to structure...@googlegroups.com
I think you’re getting a binding conflict. I’m guessing you’ve got the StructureMap.Web nuget package in there somewhere? That apparently references StructureMap 4.0.0, so when you call HttpContextScoped(), you get the blowup.

In case you wondering, this exact kind of scenario is why I refuse to sign StructureMap.

You might try a binding redirect from 4.0 to 4.5.3 to get around that. If you’re using Web API though, do you even need the HttpContextScoped() thing? If you’re using a nested container per request, that should no longer be necessary.




--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-us...@googlegroups.com.
To post to this group, send email to structure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/structuremap-users/b2a31d2b-2e72-457c-a6e8-fae8716cfea6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Untitled.png>

Reply all
Reply to author
Forward
0 new messages