0

I downloaded the LinqToLdap GIT example project that uses SimpleInjector as the Inversion of Control container and translated the code accross to Castle Windsor. My config code looks like this:

container.Register(Component.For<ILdapConfiguration>()
            .UsingFactoryMethod(() =>
            {
                var config = new LdapConfiguration()
                .AddMapping(new UserImageMapping())
                .AddMapping(new UserMapping());

                config.ConfigurePooledFactory("my.ad.server");
                return config;
            }));


and the Directory Context is registered as:

 container.Register(Component.For<IDirectoryContext>()
            .UsingFactoryMethod(() => new DirectoryContext(container.Resolve<ILdapConfiguration>())).LifestyleSingleton());


This issue I've come across is when using the DirectoryContext in a query such as:

var photo =  context.Query<UserPhoto>().FirstOrDefault(u => u.EmployeeId == userQuery.Id);


The context object has a list of providers associated with it and the count of these providers keeps increasing every time a query is made. So much so that there's hundreds after a few minutes of use. I guess it's something to do with correct disposal of the context, but when I explicitly dispose of the context subsequent queries fail since the context is disposed and for some reason a new one isn't created. Can anyone help?

Ian Barrett
  • 106
  • 4

1 Answers1

0

Turns out to be a slight bug in the LinqToLDAP code. The developer has identified the issue and it will be fixed in the next release! (R 3.3.2)

Ian Barrett
  • 106
  • 4