This topic applies to .NET version only
MarshalByRef objects from .NET Remoting can not be stored by
db4o.
MarshalByRef objects are not really objects. They are proxy objects to instances, which live on another machine. There are 2 cases to distinguish:
1. Use marshal by value technology for the persistent object. In this case the object implements ISerializable interface and can be stored by db4o without any problems. The object is created on the client and is passed to the server using MarshalByRef proxy.
In the example, TestValue class should be stored to db4o. TestValue implements ISerializable. In order to make TestValue class available to the server and to the client it is declared in a separate class library RemotingClasses.
TestValueServer class extends MarshalByRefObject and plays the role of a carrier between the client and the server. TestValue instance is created on the client and passed to the TestValueServer, which runs as a service on the server. TestValueServer then stores TestValue object to the database and retrieves its value on request.
Download the example solution: c#, VB
2. If using MarshalByRef object is mandatory for you, use the following configuration:
configuration.ObjectClass("System.Runtime.Remoting.ServerIdentity,
mscorlib").Translate(new TTransient());
configuration.ObjectClass("System.Threading.TimerCallback,
mscorlib").Translate(new TTransient());
The TTransient translator will prevent instances of ServerIdentity and
TimerCallback from being stored within a db4o database. These classes are
protected internal classes within the .NET Framework. When retrieving your
MarshalByRef objects from db4o, you will need to re-marshal them.
In the following example Test object extends MarshalByRefObject. Test object lives on the server and can store itself to db4o when a request is received from the client. The configuration above is used to make it storable with db4o.
Download the example solution: c#, VB.
Note: in many cases using db4o client-server version can be a better option for a remote persistence.