views:

70

answers:

1

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...

+1  A: 

If you are going to be using windsor castle there is a Remoting Facility that will help you out. Have a look at the documentation.

Rohan West
Thx, I have read the documentation carefully and would just like to make sure that I am getting it right. In my case, where I need to have the server to build the services with constructor injection, only the 3rd scenario will work out, right? http://www.castleproject.org/container/facilities/trunk/remoting/containersconnected.html
Christoph