Using IOC in a remoting scenario

Posted by Christoph on Stack Overflow See other posts from Stack Overflow or by Christoph
Published on 2010-03-16T21:25:01Z Indexed on 2010/03/16 21:31 UTC
Read the original article Hit count: 625

Filed under:
|
|
|
|

I'm struggling with getting IOC to work in a remoting scenario. I have my application server set up to publish Services (SingleCall) which are configured via XML.

This works just like this as we all know:

RemotingConfiguration.Configure(ConfigFile, true);

lets say my service looks like that (pseudocode)

public class TourService : ITourService
{
    IRepository _repository;
    public TourService()
    {
         _repository = new SqlServerRepository();   
    }
}

But what I rather would like to have sure looks like this:

public class TourService : ITourService
{
    IRepository _repository;
    public TourService(IRepository repository)
    {
         _repository = repository;   
    }
}

On the client side we do something like that (pseudocode again):

(ITourService)Activator.GetObject(ITourService, tcp://server/uri);

This prompts the server to create a new instance of my TourService class...

However this doesn't seem to work out well because the .NET Remoting Infrastructure want's to know the type it should publish but I would rather like to point it to the way how it could retrieve the object it should publish. In other words, route it through the IOC process pipe of - let's say windsor castle - for example.

Currently I'm a bit lost on that task...

© Stack Overflow or respective owner

Related posts about ioc

Related posts about remoting