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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:10:55+00:00 2026-06-13T02:10:55+00:00

I have some simple classes that need to be disposed a the end of

  • 0

I have some simple classes that need to be disposed a the end of the request.

For that end I call the Dispose method on those objects from the Application_EndRequest event in Global.asax.

This “works fine on my machine” but causes some problems on my production server where I get Cannot access a disposed object. This happens in some MVC helpers.

It seemed to me like Application_EndRequest is triggered at the end of the request. Is this not the case? Is there another event I should be using to dispose my 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-06-13T02:10:56+00:00Added an answer on June 13, 2026 at 2:10 am

    Application pool issues – likely

    I suspect that your disposable object isn’t bound to request but rather app wide (it may be instantiated per request but it may be using some shared resources). As long as you’re testing your application in development environment it seems to behave as expected but as soon as you put it in production you get issues. This indicates you may have problems with application pool.

    IIS web application pool capabilities actually instantiate several HttpApplication instances for your application and they may all share common disposable resources. If that’s the case with your disposable object and you’re sharing it it may be that it isn’t thread safe. The same would be true when you wouldn’t wrap your shared resource usage inside thread safe operations.

    That’s why it may happen that while one request is in progress another one begins and the first one disposed the object while the second process still uses it.

    More information is always helpful

    If you’d explain the nature of your disposable object/resource and how you’re using it in your application we could help you much better. But in the meantime, you could read my blog post that talks about application pools and handling them. It’s not about disposable objects per se, but you may still find all the information very useful and helpful.

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

Sidebar

Related Questions

I have a (somewhat) simple question about android. I have some classes that contain
I have built a simple rails app with three classes that inherit from ActiveRecord
I have some simple constraints involving multiplication of reals in z3 that are producing
Is there some way to avoid this. I have a lot of classes that
I need to have some of my C++ classes, functions and namespaces renamed as
I'm working on some project, and need some simple advice. I have one base
Lets say I have some simple classes for a twitter-like app: User Post A
We have a DAL that we're using with NHibernate.Search , so classes that need
If have a union that currently foresees some simple data types: union Value {
I have some global variables (classes) that as I understand have created before main()

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.