torrud
March 9th, 2005, 10:31 AM
Hi,
I wrote a windows-service for handling files. Therefore I use Remoting. Because I am lazy. I wrote an abstract factory for creating broker-objects.
Here is the body:
public object GetBroker(Type brokerType)
{
//implementation
}
This method works great and instancing the correct classes. But I have a problem to cast the object against a given Interface. Because I use remoting, I have a shared dll which contains the interface of the broker. And the implementation class of a broker implements the related interface. On the client I want to cast against this interface, but I get an error. I use the following commands:
IBrokerFactory _factory = (IBrokerFactory)Activator.GetObject(typeof(IBrokerFactory),"tcp://192.168.0.1:8000/FileService.BrokerFactory");
IFileInfoBroker _broker = _factory.GetBroker(typeof(IFileInfoBroker)) as IFileInfoBroker;
I get the factory and the method GetBroker instantiate the correct broker and give it back, but the cast fails on the client and I don't know the reason.
Any hints?
I wrote a windows-service for handling files. Therefore I use Remoting. Because I am lazy. I wrote an abstract factory for creating broker-objects.
Here is the body:
public object GetBroker(Type brokerType)
{
//implementation
}
This method works great and instancing the correct classes. But I have a problem to cast the object against a given Interface. Because I use remoting, I have a shared dll which contains the interface of the broker. And the implementation class of a broker implements the related interface. On the client I want to cast against this interface, but I get an error. I use the following commands:
IBrokerFactory _factory = (IBrokerFactory)Activator.GetObject(typeof(IBrokerFactory),"tcp://192.168.0.1:8000/FileService.BrokerFactory");
IFileInfoBroker _broker = _factory.GetBroker(typeof(IFileInfoBroker)) as IFileInfoBroker;
I get the factory and the method GetBroker instantiate the correct broker and give it back, but the cast fails on the client and I don't know the reason.
Any hints?