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

  • SEARCH
  • Home
  • 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 6028359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:43:42+00:00 2026-05-23T04:43:42+00:00

I can see how I can instantiate objects of classes using autofac, and then

  • 0

I can see how I can instantiate objects of classes using autofac, and then pass these to db4o for storage. When it’s time for me to retrieve the object instances from db4o, how do I register the objects with autofac?

I was originally planning on using db4o’s MSBuild tool to implement transparent activation/persistence, but it looks like that I may have to manually implement the IActivatable interface for all my Model objects so that I can put in extra code in IActivatable::Bind() to register this pointers as they are activated.

To make matters worst, I foresee that the implementation of IActivatable::Bind() will have to access a Singleton of the current Autofac lifetime scope to do the registration against. Obviously, I can’t pass in the current lifetime scope to the object instance that db4o is activating. As bad as passing the scope around is, I can imagine the groans from people considering sticking the current life scope in a public Singleton.

An alternative seems to be to implement db4o’s Type Handlers and intercept object instantiation at that point, but that seems like undoing any gains I had of using db4o for storing objects.

Or did I just go a little too crazy with the idea of using autofac to instantiate all objects? (e.g. I’ve got a hammer and everything looked like a nail.) Should Model objects just be instantiated by plain old ‘new’ and whatever magic that db4o uses? In other words, use autofac only with my View, ViewModel and Controller objects.

  • 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-05-23T04:43:43+00:00Added an answer on May 23, 2026 at 4:43 am

    I would recommend to replace every ‘new’ with an Autofac instantiation. My rule of thumb is that I when a object needs complex dependencies (not simple collections, core CLR types, other simple objects), then I let Autofac do the work. Simple domain object I usually just use the new operator or a create a factory.

    I’m not 100% sure if I get your question right. You want to bind some service to your domain models when they are instantiated? Well then I recommend to use events. You can use the db4o events to detect when an object gets stored, activated, etc. In such a event listener you can use the current Autofac scope to pass additional services.

    Btw. the IActivatable::Bind() stuff is already called by db4o. You don’t need to do anything else.

    In general I would try to properly scope everything and not misuse Autofac as a service-locater.

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

Sidebar

Related Questions

I can see people asking all the time whether multiple inheritance should be included
As you can see below, in the constructor I'm instantiating a validation object so
We can see in a directory files ordered by Name in Windows Explorer. If
I can see line numbers in my error logs in our development environment, in
I can see some options available: 1) Use PEAR's POP3 class --> tried it,
I can see in the postgresql logs that certain simple queries (no joins and
As you can see this is a question from a non web developer. I
As you can see here and here I'm not a good friend of asp.net
As you can see on the question, what is your advice about stoping hit
As far as I can see Solutions Architect is just a different marketing term

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.