Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:23:43+00:00 2026-05-25T01:23:43+00:00

I am trying to register all classes that implement my IProcess<T1, T2> interface with

  • 0

I am trying to register all classes that implement my IProcess<T1, T2> interface with Windsor. To accomplish this I have the following code in my installer:

        // Register all implemented process interfaces
        var procTypes = AppDomain.CurrentDomain
                                 .GetAssemblies()
                                 .SelectMany(x => x.GetTypes())
                                 .Where(x => x.IsDerivedFromOpenGenericType(typeof(IProcess<,>)))
                                 .ToList();

        foreach (var procType in procTypes)
            foreach (var procInterface in procType.GetInterfaces().Where(x => x.IsDerivedFromOpenGenericType(typeof(IProcess<,>))))
                container.Register(Component.For(procInterface).ImplementedBy(procType).LifeStyle.Transient);

One of the classes I a trying to register is the following:

public class PositionProcesses 
    : IProcess<CreatePositionParams, PositionDisplayViewModel>,
      IProcess<EditPositionParams, PositionDisplayViewModel>
{
}

The first interface gets registered correctly, but upon registering the second interface to be implemented by this class, I am getting the following error:

Test method MyJobLeads.Tests.Controllers.PositionControllerTests.Windsor_Can_Resolve_PositionController_Dependencies threw exception: 
Castle.MicroKernel.ComponentRegistrationException: There is a component already registered for the given key MyJobLeads.DomainModel.Processes.Positions.PositionProcesses

on the first loop iteration my variables are:

+       procInterface   {Name = "IProcess`2" FullName = "MyJobLeads.DomainModel.Data.IProcess`2[[MyJobLeads.DomainModel.ProcessParams.Positions.CreatePositionParams, MyJobLeads.DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MyJobLeads.DomainModel.ViewModels.Positions.PositionDisplayViewModel, MyJobLeads.DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}   System.Type {System.RuntimeType}
+       procType    {Name = "PositionProcesses" FullName = "MyJobLeads.DomainModel.Processes.Positions.PositionProcesses"}  System.Type {System.RuntimeType}

on the second:

+       procInterface   {Name = "IProcess`2" FullName = "MyJobLeads.DomainModel.Data.IProcess`2[[MyJobLeads.DomainModel.ProcessParams.Positions.EditPositionParams, MyJobLeads.DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MyJobLeads.DomainModel.ViewModels.Positions.PositionDisplayViewModel, MyJobLeads.DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"} System.Type {System.RuntimeType}
+       procType    {Name = "PositionProcesses" FullName = "MyJobLeads.DomainModel.Processes.Positions.PositionProcesses"}  System.Type {System.RuntimeType}

(both of those are from the VS debugger.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:23:44+00:00Added an answer on May 25, 2026 at 1:23 am

    You should use convention based component registration

    BasedOnDescriptor processes = AllTypes.FromAssembly(assemblyWithProcesses)
        .BasedOn(typeof (IProcess<,>))
        .WithService.AllInterfaces()
        .Configure(x => x.LifeStyle.Transient);
    
    container.Register(processes)
    

    EDIT removed first sample as mentioned by @Krzysztof-kozmic

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to register the following class using the fluent interface: public class
I am sure this has been asked already, but I have been trying all
I'm trying to automatically register all reports in a unity container. All reports implement
I am trying to register a WebDeleting event receiver within SharePoint. This works fine
I am trying to find all terms and courses that apply to a contact.
I'm trying to write a game and implement scripting so that later on in
I have a legacy application that I'm trying to port to Java EE. Presently
I'm trying to register a Servlet in Jetty 7.0 programmatically. All the examples I
I´m trying to work out a problem with registering my configuration classes. I have
I'm trying to create a splash screen that shows assemblies (all referenced library) loading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.