Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:02:06+00:00 2026-06-03T07:02:06+00:00

I have a db4o database that was generate by a Java app and I’m

  • 0

I have a db4o database that was generate by a Java app and I’m trying to read it using a C# app.

However, when running the following line of code:

IObjectContainer db = Db4oEmbedded.OpenFile(@"..\..\..\Databases\people.db4o");

I get the following error:

Unable to cast object of type
‘Db4objects.Db4o.Reflect.Generic.GenericObject’ to type
‘Db4objects.Db4o.Ext.Db4oDatabase’.

Any ideas? I know there are person objects that contain personId fields (along with others) in the DB. I’m using db4o version 8. I’m not sure what version was used to generate the database.

The entire program is:

using System;
using System.Collections.Generic;
using System.Linq;

using Db4objects.Db4o;
using Db4objects.Db4o.Config;

using MyCompany.Domain;

namespace MyCompany.Anonymizer
{
    internal class Program
    {
        // Private methods.

        private static IEmbeddedConfiguration ConfigureAlias()
        {
            IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();

            configuration.Common.AddAlias(new TypeAlias("com.theircompany.Person", "MyCompany.Domain.Person, MyCompany.Domain"));

            configuration.Common.Add(new JavaSupport());

            return configuration;
        }

        private static void Main(string[] args)
        {
            IObjectContainer db = Db4oEmbedded.OpenFile(@"..\..\..\Databases\people.db4o");

            try
            {
                IList<Person> result = db.Query<Person>();

                for (int i = 0; i < result.Count; i++)
                {
                    Person person = result[i];

                    Console.WriteLine(string.Format("Person ID: {0}", person.personId));
                }
            }
            finally
            {
                db.Close();
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:02:09+00:00Added an answer on June 3, 2026 at 7:02 am

    The most common scenario in which this exception is thrown is when db4o fails to resolve the type of a stored object.

    In your case, db4o is failing to read one of its internal objects which makes me believe you have not passed the configuration to the OpenFile() method (surely, the code you have posted is not calling ConfigureAlias() method);

    Keep in mind that as of version 8.0 no further improvement will be done regarding cross platform support (you can read more details here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to admit that I'm new to Java and Android. db4o seems to
For db4o, I'm trying to find the LINQ code that generates the following SODA:
Currently I am trying to integrate db4o into my App. I have a Model
I have an object model that I want to store using an embedded database.
I am writing an application using an object database ( db4o ) and in
I'm new to Android programming however I do have some Java experience. What I
the way i'm using db4o is really just read-only. I will package a db
In my DB4O database I have an amount of Book objects Book +string: Title
I am using db4o as DBMS and I have a question: Is there any
I'm currently trying out db4o (the java version) and I pretty much like what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.