For my current project I’m trying to implement a factory pattern using remoting. This seems to be more difficult than I imagined. I’ve done the following:
– Create an Interfaces project containing an IProductFactory and an IProduct.
– Create a Class Library which implements Product and ProductFactory and is hosted in IIS through a web.config.
– Create a project which makes a ProductFactory and uses this to create a product, all based on the interfaces.
Everything seems to be ok: the ProductFactory is instantiated perfect, and properties and methods with ‘normal’ returntypes can be accessed, untill I try to use the ProductFactory to create a Product. I receive a message stating there is "No assembly associated with XML key". In that same message, there’s a link to the key (I guess) starting with "http://schemas.microsoft.com/clr/nsassem/". I tried to set TypeFilterLevel to "Full" but that didn’t solve anything. I’ll try to find an answer, and when I do I will keep you posted. If you have any idea, will you drop me a line?
P.S. writing my own (de)serilization seems to do the trick, but I would like to do without that…
Edit: apparently, classes which are instantiated by remoted classes, have to inherit MarshalByRefObject because they are remoted also. This means not the entire object is sent over the line, but only the interface. And that means that every call to a property or a method goes to the server component in stead of happening on the client. This kind of ‘chatty’ interface is not what I intended. As a solution, I’ll probably use the Updater Application Block to keep all the clients in sync with the objects on the server automaticaly.