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 1095411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:07:11+00:00 2026-05-17T00:07:11+00:00

Inside a DLL, we’ve defined two classes (Class1 and Class2) which inherit from an

  • 0

Inside a DLL, we’ve defined two classes (“Class1” and “Class2”) which inherit from an interface (“IInterface”) and a base class (“BaseClass”).

We’re using the Castle Windsor’s Fluent Registration API ( http://using.castleproject.org/display/IoC/Fluent+Registration+API ) to automatically register all the classes inheriting from “BaseClass” (inside that DLL) to their respective interfaces.

For specific personalization, we’ve used (since today) a “castle.xml” file, which overrides (with “component” tags) the associations between interfaces and concrete classes (registered by the Fluent Registration Api). We load that xml file inside the WindsorContainer’s constructor.

The code is something like this:

        //container's initialization:
        var resource = new FileResource("Castle.xml");
        var interpreter = new XmlInterpreter(resource);
        var container = new WindsorContainer(interpreter);
        container.AddFacility<TypedFactoryFacility>();

        //...

        //automatic type registration:
        container.Register(
            AllTypes
                .FromAssemblyContaining<BaseClass>()
                .BasedOn<BaseClass>()
                .WithService.Select(
                    (t1, t2) => t1.GetInterfaces()
                                    .Except(new[] {typeof (IDisposable)})
                                    .Union(new[] {t1}))
                .Configure(a => a.Named(a.ServiceType.Name)
                                    .LifeStyle.Transient)
                .AllowMultipleMatches()
            );

By default, if we ask Castle for IInterface object, we get “Class1”; to obtain “Class2”, we have to specify it inside the “Castle.xml” file.

Today, I’ve tried to get rid of the castle.xml, specifying the “Component” directives inside the fluent configuration (BEFORE the “AllTypes” directive):

        container.Register(
            Component
                .For<IInterface>()
                .ImplementedBy<Class2>()
                .LifeStyle.Transient);

… but we still get a Class1 object, as if the “AllTypes” fluent directive overrode the “Component” one (and it’s strange, ‘cos the “component” directive inside the xml file works).

What am I doing wrong?

EDIT: I was accessing to the component by key name, “.Named()” solved the problem (thanks to Krzysztof):

        container.Register(
            Component
                .For<IInterface>()
                .ImplementedBy<Class2>()
                .Named(typeof(IInterface).Name)
                .LifeStyle.Transient);
  • 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-17T00:07:12+00:00Added an answer on May 17, 2026 at 12:07 am

    Just so that the question does not appear as unanswered, the answer is in the comments above.

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

Sidebar

Related Questions

I have a class inside a DLL ( Database.dll ) which has a static
What steps are needed to compile Version Information inside a windows DLL from the
I have a small issue with forms that are created from inside a DLL.
I have an application, myprogram.exe, which calls functions and code inside a dll, one
How can I access the functions inside a third-party DLL from VBA (Excel)? Also,
I have a C++ class(inside a dll project) whose member variables are boost::shared_ptrs to
What is the right way to handle exceptions thrown from inside a DLL in
I'm am trying to debug a DLL which is called from a VC++ application,
Can i really see inside a dll file, for the methods or the classes
Someone explain why the next code returns a pointer inside ntdll.dll? GetProcAddress(LoadLibraryA(kernel32.dll), EncodePointer); GetProcAddress(LoadLibraryA(kernel32.dll),

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.