Mac wrote:
Devildog74 wrote:
Also, exposing the data access adaper over remoting is not the thing to do. Hide that in the facade. Only let the facade objects talk to the data access adaper.
Thanks.
I've tried to create a standart wrapper over DataAccessAdapter just to practice in remoting.
And i've got some problems, like if you are passing some object as parameter, it must derive from MarshalByRefObject. So, will I use facade pattern or not, I will meet the same problems, i think.
It's not wise to expose the adapter over the remoting channel because it contains an open db connection which is not serializable. So the adapter itself isn't marked serializable as well. You therefore should create a remoting service which calls the adapter object, accepts entity objects and returns entity objects.
I still don't know how to pass EntityCollection as parameter - i tried to make following:
I took source of CollectionBase, rewrote it to derive from MarshalByRefObject. Made EntityCollectionBase derive from my CollectionBase class.In the CollectionBase class the ISerializable interface is implemented, but when i try to pass it to the adapter, i still got an error "Serialization will not desetrialize delegates to non-public methods." So, I'm stuck...
I've searched across the net, and found that this exception will occur if ISerializable is not implemented. But it is implemented! I just dont' know what to do now...
You don't need to do this. Entity objects and entity collection objects are not derived from MarshalByRefObject for a reason: when you change a property with such an object you'd get a remoted call, which is very inefficient. Therefore entity objects and entitycollections are serializable and are passed by value: you return an entitycollection from a remoted method, the collection gets serialized into soap or binary depending on your formatter of choice, and at the client side again deserialized into an object. You change values and pass back the object to a remoted method on the server.
All objects which should be serializable are also serializable, so you can pass an entity collection object as a parameter to a remoted method without problems as well as returning one from a remoted method.
Do NOT go the MarshalByRefObject route, it's not used for objects with data, but for objects which deliver a service, i.e. expose methods.