Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 02:42
    natalie-perret-1986 commented #1283
  • Jun 14 16:03
    dariogriffo edited #1843
  • Jun 14 08:18
    dnfadmin commented #1843
  • Jun 14 08:17
    dnfadmin commented #1843
  • Jun 14 08:17
    dariogriffo opened #1843
  • Jun 09 11:26
    VilleHakli edited #1842
  • Jun 09 07:55
    VilleHakli opened #1842
  • Jun 08 04:54

    mysticmind on master

    Bump up version to rc.2 (compare)

  • Jun 04 21:25

    jeremydmiller on master

    deleted some tests that are dup… (compare)

  • Jun 04 20:58
    jeremydmiller commented #1840
  • Jun 04 20:57
    jeremydmiller closed #1840
  • Jun 04 20:57

    jeremydmiller on master

    Add multi-tenancy failure scena… fixed the default filters for L… (compare)

  • Jun 04 20:17
    jeremydmiller commented #1840
  • Jun 04 15:25
    CodingGorilla labeled #672
  • Jun 04 15:25
    CodingGorilla opened #672
  • Jun 04 09:51
    flick556 edited #1841
  • Jun 04 09:51
    flick556 opened #1841
  • Jun 04 07:55
    Hawxy synchronize #1840
  • Jun 04 07:41
    Hawxy opened #1840
  • Jun 03 13:04

    mysticmind on master

    Update GH NuGet publish with --… (compare)

rafae11
@rafae11
Hi wanted to ask how do i inject a mock object?
container.Inject<IAzureCloudStorageWrapper>(() => mockAzureStorage.Object);
I get the error cannot convert lambda expression to type 'IAzureCloudStorageWrapper' because it is not a delegate type.
TarunKumarG
@TarunKumarG

Hi Team,

I am facing an issue with dependency registration.

Structuremap is asking us to register the dependcies which are part of nuget package. We are not suppose to register the nuget package or any other third party packages dependencies in our projects as these are already registered in their own projects.
Is there a way to tell structuremap that it is already registered in packages.

Please help.

Issue/Exception:
StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type 'HM.Disco.PurchaseProduct.DataProviders.IPurchaseProductDataProvider'

There is no configuration specified for HM.Disco.PurchaseProduct.DataProviders.IPurchaseProductDataProvider

1.) new PreAdvicesApprovedEventHandler(Default of IPurchaseProductDataProvider, Default of ISecurityDataProvider, Default of IHmOrderUpdater, Default of IHmOrderUpdateEmailComposer, Default of IFeatureAccessManager)
2.) HM.Disco.ItOps.Gateway.HMOrder.PreAdvicesApprovedEventHandler
3.) Instance of HM.Disco.ItOps.Gateway.HMOrder.PreAdvicesApprovedEventHandler
4.) Container.GetInstance(HM.Disco.ItOps.Gateway.HMOrder.PreAdvicesApprovedEventHandler)

Thanks,
Jeremy D. Miller
@jeremydmiller
@TarunKumarG It’s clearly not registered, or you wouldn’t be getting that exception
TarunKumarG
@TarunKumarG
Even we thought the same, but these depedencies were registered in the nuget packages that we were referring to
if they were already registered in the package itself, why there is a need to register them in the project that the package is used.
@jeremydmiller
Jeremy D. Miller
@jeremydmiller
Not in the StructureMap container you’re actually using. Have you checked the WhatDoIHave() diagnostics to verify that?
TarunKumarG
@TarunKumarG
No, I didnt check WhatDoIHave(), let me check now .
CarlosOnline
@CarlosOnline

Looking to use StructureMap in Azure Function to do multi tenancy. Found a sample that replaces the ServiceProvider in a Web Api (4 years old), wondering if that approach would work for Azure Functions.

Also is there a recent sample that works with .net core 3.1 Azure Functions?

Mark Warpool
@CodingGorilla
@CarlosOnline Consider using https://github.com/jasperfx/lamar instead, it's the official replacement for StructureMap. Although I can't speak to how it would work with Azure functions (haven't tried it).
TarunKumarG
@TarunKumarG
@jeremydmiller , i just verified with WhatDoIHave(), i have the dependencies which are needed in the container, but why it is explicitly asking us to register again ?
please suggest
Jeremy D. Miller
@jeremydmiller
I don’t know to be honest. There’s something else going on I can’t see.
TarunKumarG
@TarunKumarG
ok, Can anyone give any suggestions
Mark Warpool
@CodingGorilla
@TarunKumarG How does it "ask us to register again"?
TarunKumarG
@TarunKumarG
@CodingGorilla
i dont why but it is throwing below exception

Issue/Exception:
StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type 'HM.Disco.PurchaseProduct.DataProviders.IPurchaseProductDataProvider'

There is no configuration specified for HM.Disco.PurchaseProduct.DataProviders.IPurchaseProductDataProvider

1.) new PreAdvicesApprovedEventHandler(Default of IPurchaseProductDataProvider, Default of ISecurityDataProvider, Default of IHmOrderUpdater, Default of IHmOrderUpdateEmailComposer, Default of IFeatureAccessManager)
2.) HM.Disco.ItOps.Gateway.HMOrder.PreAdvicesApprovedEventHandler
3.) Instance of HM.Disco.ItOps.Gateway.HMOrder.PreAdvicesApprovedEventHandler
4.) Container.GetInstance(HM.Disco.ItOps.Gateway.HMOrder.PreAdvicesApprovedEventHandler)

Jeremy D. Miller
@jeremydmiller
“cannot be automatically determined for type “ — might be the key thing there. Whatever that service is, does SM have all its dependencies? It might not be able to determine a usable constructor function
yuren1978
@yuren1978
Hello, we are using nested container in asp.net webapi (NOT .net core), and we are seeing ObjectDisposedException("StructureMap Nested Container") in the middle of http request, does anybody has any idea what will cause that.
we are using structure map through out the application, but it does seem only happening at one particular call, I don't see how this call is different with other calls, by the way, this only happens under the load.
we have tried to upgrade to latest version of structure map, and still seeing the same issue.
yuren1978
@yuren1978
Here is the exact error : Cannot access a disposed object. Object name: 'StructureMap Nested Container'. StackTrace: at StructureMap.Container.assertNotDisposed() at StructureMap.Container.GetInstanceT at * our application code.
Jeremy D. Miller
@jeremydmiller
Something is hanging on to the nested container when it shouldn’t be. Are you injecting the IContainer into something?
yuren1978
@yuren1978
yes, we inject into constructructor , so it can be used to resolve other instance with _container.GetInstance, and it's where it bombs, is this not the right way of doing it?
yuren1978
@yuren1978
There is a shared document library we use which takes IContainer in constructor, and we subsequently use that injected container to resolve other object
Ben Collins
@aggieben
I'm having some trouble getting .Inject() to work like I think it should with SM 4.7, and I was wondering if anyone here could offer some insight. For some reason, it appears as though child.Inject has no effect at all. I have a linqpad script here: https://gist.github.com/aggieben/a389b01b7ba637a265299c1b2f9337d0
Ben Collins
@aggieben
I'm still playing around with examples, but here's a pretty good simple repro:
public void TestSimpleDependency()
{
    /*
        Dependency hierarchy:
            IFooRepository
                => IFoo
    */

    var container = new Container(cfg =>
    {
       cfg.For<IFoo>().Singleton().Use<Foo>();
       cfg.For<IFooRepository>().Singleton().Use<FooRepository>();
    });

    var child = container.CreateChildContainer();

    var substituteFoo = Substitute.For<IFoo>();
    child.Inject(substituteFoo);

    var fooRepo = child.GetInstance<IFooRepository>();
    fooRepo.Foo.Should().BeSameAs(substituteFoo); // fails assertion here
}
Jeremy D. Miller
@jeremydmiller
I’d guess that the bug is due to the foo repository being a singleton. YOu might try it ContainerScoped() instead
Ben Collins
@aggieben
hmm. if I configure IFooRepository repository like this: cfg.For<IFooRepository>().ConatinerScoped().Use<FooRepository>(), then the test works
I also tested it with child.EjectAllInstances<IFooRepository>() in the singleton case, and it still failed
my problem here is that I'm going to be stuck with using singletons; that's not something I can change in the real code :-(
Jeremy D. Miller
@jeremydmiller
And this is also the time when I remind you that StructureMap is no longer supported and I’m encouraging folks to move to Lamar
And this kind of issue is a good example of why I wanted out of supporting SM:(
Ben Collins
@aggieben
yeah. I wish I could, but I'm also stuck on that count as well, at least for the time being

And this kind of issue is a good example of why I wanted out of supporting SM:(

completely understand. I feel the same about the production code I'm trying to write tests for

Ben Collins
@aggieben
@jeremydmiller thanks for the tip on ContainerScoped. That might actually be good enough to get me out of my predicament
Piyush Gupta
@creativepiyush_twitter
On upgrading to .net framework 4.8, structure map started to fail
StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type 'PartStream.Core.Services.IPartService'
Works on local but giving error on server
any pointers?
Jeremy D. Miller
@jeremydmiller
Always start with the WhatDoIHave() diagnostics. If you’ve got type scanning happening, look at the type scanning diagnostics. It’s not unlikely that you’ve got a dependency problem that keeps type scanning from being able to look through an assembly.
Jacek Kowalski
@kicaj29
hi, maybe somebody could take a look on my issue reported here https://stackoverflow.com/questions/66528541/structuremap-does-not-see-types-in-asp-net-core-net5
Ruslan1213
@Ruslan1213

Hi all,

guys, I have a periodical NullReferenceException when I'm trying to get instance using ObjectFactory.GetInstance<MyService>() but I cannot understand why this happens periodicaly but not permanent.

Could you help me please? Maybe this is a know issue? I use StructureMap 2.6.4.1, StructureMap.MVC4 2.6.4.3. Platform: .NET Framework 4.6.1

---> System.NullReferenceException: Object reference not set to an instance of an object. at StructureMap.Pipeline.ObjectBuilder.ApplyInterception(Type pluginType, Object actualValue, BuildSession session, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ObjectBuilder.cs:line 56 --- End of inner exception stack trace --- at StructureMap.Pipeline.ObjectBuilder.ApplyInterception(Type pluginType, Object actualValue, BuildSession session, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ObjectBuilder.cs:line 54 at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ObjectBuilder.cs:line 27 at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession.cs:line 176 at StructureMap.Container.GetInstance[T]() in c:\BuildAgent\work\767273992e840853\src\StructureMap\Container.cs:line 155

Jeremy D. Miller
@jeremydmiller
@Ruslan1213 Is there any way you can get on a more modern version of StructureMap?
Ruslan1213
@Ruslan1213
@jeremydmiller , No, unfortunately I can not raise the version because there are many dependencies:(
Jeremy D. Miller
@jeremydmiller
Because strong typing, or diamond dependencies, or both? And I’m sorry.
alexanderbright
@alexanderbright

@Ruslan1213 Is there any way you can get on a more modern version of StructureMap?

Hi @jeremydmiller . Now there is no way to migrate to a new version as far as it contains breaking changes but we have quite complex project. Is there any woraround for this problem in our current version?