Accessing db4o database created and filled in with a .NET application or library from another .NET application or library shows an empty database.
db4o class name format in db4o consists of the full class name and assembly name:
Namespace.ClassName, AssemblyName
Two different .NET applications (libraries) usually have different assembly names. If you do not use aliasing, the class name will be appended with the current application assembly name.
In order to access db4o persistent classes from different applications (libraries) you will need to use an Alias. For example:
Application1.exe ("Application1" assembly):
objectContainer.Store(new MyClasses.Pilot("David
Barrichello",99))
// internally the class is saved as "MyClasses.Pilot,
Application1".
Application2.exe ("Application2" assembly):
c#:
// create an Alias
for the MyClasses.Pilot,
Application1:
IEmbeddedConfiguration configuration =
Db4oEmbedded.NewConfiguration();
configuration.Common.AddAlias(new
TypeAlias("MyClasses.Pilot, Application1", " MyClasses.Pilot, Application2"));
IObjectContainer container =
Db4oEmbedded.OpenFile(configuration, "reference.db4o");
// now you query as usual
IObjectSet result = container.QueryByExample(new
Test());
VB:
// create an Alias for the MyClasses.Pilot,
Application1:
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.AddAlias(new
TypeAlias("MyClasses.Pilot, Application1", " MyClasses.Pilot, Application2"))
Dim container As IObjectContainer =
Db4oEmbedded.OpenFile(configuration, "reference.db4o")
// now you query as usual
Dim result As IObjectSet = container.QueryByExample(New
Test())
For more information see Class Name Format In .NET and Aliases.