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

  • SEARCH
  • Home
  • 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 1091931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:36:29+00:00 2026-05-16T23:36:29+00:00

I having some problems implementing IOC using windsor. I have several different implementations of

  • 0

I having some problems implementing IOC using windsor. I have several different implementations of a data access class and i want to use windsor to be able to specify which data access class to use when using a business object. See the code below

public interface IPersistable
{
    bool Save();
    bool Delete();
}

public class Address
{
 public Address()
 {
 }

    public Address(IPersistable Factory)
    {
        this.DataAccess = Factory;
    }

    private IPersistable _DataAccess;

    public IPersistable DataAccess
    {
        get { return _DataAccess; }
        set { _DataAccess = value; }
    }
}

public class AddressFactoryUsingSQL : IPersistable
{

    public bool Save()
    {
        throw new NotImplementedException();
    }

    public bool Delete()
    {
        throw new NotImplementedException();
    }
}

public class AddressFactoryUsingWebService : IPersistable
{
    public bool Save()
    {
        throw new NotImplementedException();
    }

    public bool Delete()
    {
        throw new NotImplementedException();
    }
}

public class AddressFactoryUsingRepository : IPersistable
{
    public bool Save()
    {
        throw new NotImplementedException();
    }

    public bool Delete()
    {
        throw new NotImplementedException();
    }
}

Add when the class is consumed im using the following:
Address addr = new Address(new AddressFactoryUsingSQL);

I want to be able to use Windsor so i can write something similar to:

    IWindsorContainer _Container= new WindsorContainer();
    _Container.Register(Castle.MicroKernel.Registration.Component.For<IPersistable>()); //this would retrieve the IPersistable class i want to use for the Address business object
    IPersistable addrF = _Container.Resolve<IPersistable>();
    Address addr = new Address(addrF);

how do i achieve this? I get the error message,”
Type IPersistable is abstract.
As such, it is not possible to instansiate it as implementation of IPersistable service”

I want to be able to change the data access method without having to change all of my code. Also, how can i use web.config to this?

Al

  • 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-16T23:36:30+00:00Added an answer on May 16, 2026 at 11:36 pm

    The problem is that you forgot to mention your concrete type implementing IPersistable, folowing code should work:

    IWindsorContainer container = new WindsorContainer();
    container.Register(
       Component.For<IPersistable>()
         .ImplementedBy<AddressFactoryUsingSQL>());
    

    And you can use it this way:

    var persistable = container.Resolve<IPersistable>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems with the stack in java... I'm implementing quicksort using an
I am having some problems with implementing the twitter api. I am using Abraham's
I'm having some problems implementing an algorithm to read a foreign process' memory. Here
I am having some problems with the PDF files that I make using the
I'm having some problems while using PDO. It all seems correct but I am
I'm having some problems building an hierarchistic array structure - I have almost got
I'm having some problems implementing an exception system in my program. I found somewhere
I'm having some problems with implementing javascript controls in my asp.net page. I would
Im having some problems implementing an jQuery UI Accordion widget on my site. I
I'm having some problems implementing a control that shows a Busy indicator, here is

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.