Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 20 18:27

    mysticmind on master

    Remove matrix build and replace… Update npgsql min version to 4.… Disable test parallelization in… (compare)

  • Oct 20 17:39

    mysticmind on master

    Disable test parallelization in… (compare)

  • Oct 20 17:07

    mysticmind on master

    Update npgsql min version to 4.… (compare)

  • Oct 20 16:56

    mysticmind on master

    Remove matrix build and replace… (compare)

  • Oct 20 15:46

    jeremydmiller on master

    one off context wasn't marked a… (compare)

  • Oct 20 15:35

    jeremydmiller on master

    working over the integration te… Merge branch 'master' of https:… (compare)

  • Oct 20 07:45

    mysticmind on master

    Add GH Actions based CI Build (compare)

  • Oct 20 07:43

    mysticmind on master

    Disable Azure pipelines to enab… (compare)

  • Oct 19 21:04
    jeremydmiller opened #1584
  • Oct 19 21:04
    jeremydmiller milestoned #1584
  • Oct 19 21:01
    jeremydmiller milestoned #596
  • Oct 19 19:14

    jeremydmiller on master

    Better user exception for non-p… (compare)

  • Oct 19 19:13
    jeremydmiller closed #1563
  • Oct 19 18:53
    jeremydmiller closed #1559
  • Oct 19 18:53

    jeremydmiller on master

    Minor formatting changes for co… Little optimization to not fetc… (compare)

  • Oct 19 13:07
    jeremydmiller labeled #885
  • Oct 19 13:07
    jeremydmiller demilestoned #885
  • Oct 19 13:06
    jeremydmiller commented #885
  • Oct 19 13:06
    jeremydmiller closed #885
  • Oct 19 12:47
    mysticmind commented #885
Jeremy D. Miller
@jeremydmiller
What’s up?
Anish1987
@Anish1987
Hi All, I wanted to pass constructor argument in container.GetInstance but unable to find it. can anyone help?.
Jeremy D. Miller
@jeremydmiller
Look for “explicit arguments” in the documentation
Jeremy D. Miller
@jeremydmiller
image.png
Anish1987
@Anish1987
Thanks Jeremy
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