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 7175755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:22:06+00:00 2026-05-28T16:22:06+00:00

Assuming that I have the following interface and class: public interface IFooRepo : IDisposable

  • 0

Assuming that I have the following interface and class:

public interface IFooRepo : IDisposable { 

    //...
}

public FooRepo : IFooRepo { 

    //Methods here

    //Properly implement the IDisposbale.Dispose() here
}

I use Autofac as IoC container in my application and if I register this as below, can I be sure that it will disposed properly?

private static IContainer RegisterServices(ContainerBuilder builder) { 

    builder.RegisterType<FooService>().As<IFooService>();

    return
        builder.Build();
}

Or should I take further steps depending on the application type I am using. (In this case, I using ASP.NET MVC but I am considering using autofac in a WCF Web API project and a class library)

  • 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-28T16:22:07+00:00Added an answer on May 28, 2026 at 4:22 pm

    Autofac calls Dispose for all instances of components implementing IDisposable once their parent lifetime scope ends. You don’t need to do any additional work here.

    To get familiar with options provided by Autofac for managing lifetime scopes, follow @dotnetstep’s links.

    Managing lifetime scopes is a strategy that depends on your specific application not only its type (MVC or plain ASP.NET or whatever). This article about lifetimes by the Autofac’s creator gives a deep explanation of the topic.

    As for MVC3 project, I’d recommend you follow the MVC3 integration guidelines. This will make all individual HTTP requests have separate lifetime scopes created for them. Once a HTTP request is finished, Autofac will finish the associated lifetime scope and dispose all disposable resources created in that scope.

    The same effect can be achieved for an ASP.NET WebForms project by following the corresponding guidelines

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

Sidebar

Related Questions

Let's propose that I have the following class Public MyClass{ Date date; //Mutable getters
Is there a cleaner way to do the following, assuming that I have a
Assuming that I have a CronTriggerBean similar to <bean id=midMonthCronTrigger class=org.springframework.scheduling.quartz.CronTriggerBean> <property name=jobDetail ref=reminderJobDetail
Assuming that I have the following directory structure for a Python project: config/ scripts/
Assuming that I have the following code: final Catalog catalog = createCatalog(); for (int
Assuming that we have the following table: Person: PersonID, Name, Age, Gender And we
I have the following model: public class Blog { public int BlogID { get;
assuming that you have the following sentence in a requirements document The system has
I have the following record definition: -record(contact, {name, email}) Assuming that I have a
Assuming I have the following I wish to unit test: class Foo: IAMethods, IBMethods

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.