Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 18 17:14
    mysticmind commented #1357
  • Sep 18 17:12
    mysticmind labeled #1357
  • Sep 18 17:10
    mysticmind commented #1357
  • Sep 18 15:09
    jeremydmiller commented #533
  • Sep 18 14:19
    jeremydmiller closed #534
  • Sep 18 14:19

    jeremydmiller on master

    Removed the environment checks,… checkpoint: compiling after swi… checkpoint: unit tests are pass… and 1 more (compare)

  • Sep 18 14:18
    jeremydmiller commented #534
  • Sep 17 17:56
    KevinRecuerda opened #1357
  • Sep 17 16:18

    mysticmind on gh-pages

    Documentation Update for 3.8.0 (compare)

  • Sep 17 15:55
    jeremydmiller commented #534
  • Sep 17 15:07

    mysticmind on 3.8.0

    (compare)

  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:45
    jeremydmiller commented #534
  • Sep 17 14:33
    mysticmind milestoned #1302
  • Sep 17 14:33
    mysticmind demilestoned #1302
NewteqDeveloper
@NewteqDeveloper
Oh, OK, I see, I see. Let me try this out. Thank you so much for the information! :slight_smile:
Jeremy D. Miller
@jeremydmiller
Good luck
NewteqDeveloper
@NewteqDeveloper
Thank you so much!
That worked :slight_smile:
cholt0425
@cholt0425

According to this page: https://structuremap.github.io/object-lifecycle/supported-lifecycles/ If I mark something as containerscoped it should dispose of that object when the container is disposed of as long as it implements IDisposable. For some reason my object's dispose method is not being called when the child container it is in is disposed.

Here is the registration:
IOCContainer.Configure(c => { c.ForConcreteType<ExporterShellView>().Configure.ContainerScoped(); c.ForConcreteType<ExportHistoryView>().Configure.ContainerScoped(); c.ForConcreteType<ExporterShellViewModel>().Configure.ContainerScoped(); c.ForConcreteType<ExportHistoryViewModel>().Configure.ContainerScoped(); });
Yet when we dispose of the container none of those objects get their Dispose method called. I confirmed that before I dispose the container if I fetch those objects and dispose of them myself that things get cleaned up properly. Any idea what might be happening?

Jeremy D. Miller
@jeremydmiller
I think you might be getting “child” container mixed up with “nested” container.
The best I can tell you at this point is to look at the SM unit tests for ContainerScoped lifecycles. And you know that SM is no longer actively supported, right?
cholt0425
@cholt0425
I thought so too but if you look at the unit tests shown in that article they specifically show nested vs child container and they both work the same with regards to disposal
I will check the unit tests checked in and see if they differ from the documentation
Jeremy D. Miller
@jeremydmiller
Okay. Nothing has changed in regards to this in years, and all the unit tests are passing. Sorry, but I’ve got nothing for you
cholt0425
@cholt0425
There is one difference between what I'm doing and the unit test. The unit test registers at the root container. I registered it in the child container
I'll see if I'm able to run the unit tests of structure map in my environment...i don't want to go on a huge side tangent here but I'll try to add a new unit test that registers the disposable in the child container as container scoped and see if it still works
Jeremy D. Miller
@jeremydmiller
Just be warned that if it doesn’t work you’re heading into “I take pull requests” territory :(
cholt0425
@cholt0425
Yup I know
cholt0425
@cholt0425
Here was my new test and it passed. I am at a complete loss..let me confirm my version vs the latest source.
[Fact]
        public void container_scoping_with_root_child_childregister_container()
        {
            var container = new Container();

            var child = container.CreateChildContainer();

            child.Configure(_ => { _.ForConcreteType<Disposable>().Configure.ContainerScoped(); });

            // Always the same object when requested from a child container
            var childDisposable = child.GetInstance<Disposable>();
            childDisposable
                .ShouldBeTheSameAs(child.GetInstance<Disposable>());

            // Same for the child container
            child.Dispose();
            childDisposable.WasDisposed.ShouldBeTrue();

            // Same for the main container
            container.Dispose();
        }
cholt0425
@cholt0425
We were on version 4.4.5. Upgraded to 4.7.1. Still doesn't work. We originally had them set as singletons and after research figured out those won't be deleted until the root container gets disposed. I thought changing them to ContainerScoped was going to be the smoking gun. Not sure where to go from here. I guess I will have to dig further. Is there anyway to "inspect" what instances the container is watching for disposal through the debugger?
Jeremy D. Miller
@jeremydmiller
Yes, but I can’t even begin to tell you how to look for that
Mark Warpool
@CodingGorilla
@cholt0425 Do you have a lot of singleton registrations? We had a situation once where we had a singleton that depended on a container scoped item, but since the dependency was created for the singleton, we always ended up getting that one instance that was used for the singleton. Was many years ago, so I don't recall the SM version or if that would still be an issue with the [more] current versions
MOHIT KUMAR AGARWAL
@m-agarwal
x.For<ICommonInterface>().Use<CommonClassA>();
x.For<ICommonInterface>().Use<CommonClassB>();
CommonClassB override the functionality of CommonClassA. I used the named parameter but it doesn't work.
I tried a lot but failed to resolved need help to resolve this.
Both dependencies are initialized in the same container.
Jeremy D. Miller
@jeremydmiller
You’re going to have to give more information than that. The last Use call wins
Christian Chicken
@robertfriberg_twitter
I just upgraded Net Framework from 4.6 to 4.7 on all the projects in a solution and now resolution is failing. Any known issues I should be aware of before digging in? We are using version 4.7.1 and everything was fine until the netfx upgrade.
Heres my registry for reference, in case you see anything apparently stupid:
https://gist.github.com/rofr/455506bb30eea3e0d2bfc53d06902249
Jeremy D. Miller
@jeremydmiller
I don’t know of any issues, and you know this too, right? https://jeremydmiller.com/2018/01/29/sunsetting-structuremap/
Christian Chicken
@robertfriberg_twitter
@jeremydmiller thanks, yes I've read the sunsetting post. One of the few good things about the project I'm working on is they have a wrapper function around resolution so swapping structuremap for something else is done in a few minutes. That said, I'm fine using it until we have a good reason to switch.
Christian Chicken
@robertfriberg_twitter

A quick follow up... I updated to Lamar (which was very simple btw) but have the same behavior. Reading the docs I found the following, which is probably causing my bug:

Behind the scenes, Lamar is using the Assembly.GetExportedTypes() method from the .Net CLR to find types and this mechanism is very sensitive to missing dependencies.

Jeremy D. Miller
@jeremydmiller
Have you tried the type scanning diagnostics in either yet? That’ll help you unravel any issues with that
Christian Chicken
@robertfriberg_twitter
reading that doc page as we "speak", I print out the WhatDoIHave at startup and I am missing all the services not implicitly registered from a specific assembly. All use the default convention but the interfaces are in a separate assembly, for example AccountService and IAccountService. But no worries, I will figure it out. Our assembly dependencies are pretty messed up, with lots of warnings so I'll start there. If I find anything worth noting I'll be sure to let you know. Cheers and thanks for taking time to respond!
Jeremy D. Miller
@jeremydmiller
If you’re getting missing registrations, it could easily be because there’s a missing dependency after you updated .Net versions
Christian Chicken
@robertfriberg_twitter
Yes, that was the cause, thank you. Now I have TypeRepository.AssertNoTypeScanningFailures(); and _container.AssertConfigurationIsValid(); as part of my startup, fail fast ftw. That helped me locate the assembly that was failing and also which dependency failed to load.
nsirangu
@nsirangu
Is it possible to call a structure map bound class dynamically by loading it from dll?
Jeremy D. Miller
@jeremydmiller
You could I guess through a Lambda registration, but should you do that?
nsirangu
@nsirangu
IS.Process is my genereated dll by above class file..
Assembly assembly = Assembly.LoadFile(_targetPath);
Type type = assembly.GetType("IS.Process.ProcessJob");
dynamic _processJob = container.GetInstance(type);
var task1 = _processJob.Start();
task1.Wait();
Jeremy D. Miller
@jeremydmiller
If the “type” is concrete, has public constructors, and all the dependencies are known by SM, then yes
nsirangu
@nsirangu
I am trying to call start method from a console application by loading the assembly dynamically. Any thoughts on it?
Jeremy D. Miller
@jeremydmiller
I really wouldn’t want to do that myself. What’s the point of doing that?
nsirangu
@nsirangu
Projects will be loaded on demand.
Actually these are configured in database or a configuration file.
Jeremy D. Miller
@jeremydmiller
Sounds brittle
nsirangu
@nsirangu
The idea behind this is, every dll represents a process, when ever the process gets triggered the respective dll and will be loaded and called the start method to process the request.
Jeremy D. Miller
@jeremydmiller
Why not just have them hard coded in the original project? You’re having to load them into the AppDomain anyway. Why bother trying to make the loading lazy? You can get issues with the dynamic loading sometimes too
nsirangu
@nsirangu
If it doesn't work. we will go for it.
But it's working without strucuture map injection.. when using structure map it's not loading the class.
Jeremy D. Miller
@jeremydmiller
Why not?
nsirangu
@nsirangu
No Idea. I stuck there and searching for a solution
Jeremy D. Miller
@jeremydmiller
Okay