tags:

views:

65

answers:

1

Hi,

I am trying to do standard bi-directional replication as follows. However, I get a NullReferenceException. This is a separate replication project. I did import the classes involved in the original project (such as Item, Category etc.) in this replication project. What am I doing wrong? (If I debug using VS, I can see that changedObjects does have all the changed objects; there seems to be some problem inside Replicate function)

IObjectContainer local = Db4oFactory.OpenFile(@"G:\Work\School\MIS\VINMIS\Inventory\bin\Debug\vin.db4o");
IObjectContainer far = Db4oFactory.OpenFile(@"\\crs-lap\c$\vinmis\vin.db4o"); ;

IReplicationSession replication = Replication.Begin(local, far);
IObjectSet changedObjects = replication.ProviderA().ObjectsChangedSinceLastReplication();

while(changedObjects.HasNext())
               replication.Replicate(changedObjects.Next()); // Exception!!!
replication.Commit();

changedObjects = replication.ProviderB().ObjectsChangedSinceLastReplication();
while (changedObjects.HasNext())
                replication.Replicate(changedObjects.Next());
replication.Commit();

Regards,

Saurabh.

A: 

Sounds like you have forgotten to set up your databases with UUIDs and version numbers. From the official documentation:

public static IConfiguration ConfigureReplication()
{
    IConfiguration db4oConfig = Db4oFactory.NewConfiguration();
    db4oConfig.GenerateUUIDs(ConfigScope.Globally);
    db4oConfig.GenerateVersionNumbers(ConfigScope.Globally);
    return db4oConfig;
}
Anders Fjeldstad