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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:44:48+00:00 2026-06-02T15:44:48+00:00

An application I developed completely crashes about 2 times a week. When it crashes

  • 0

An application I developed completely crashes about 2 times a week. When it crashes it takes down the entire application until the Application Pool is Recycled. I can not reproduce the error in the development environment.

Below I have pasted the code that causes the crash and the error message from the application event viewer. The line that crashes the app starts with ~~~~. The message states that I have an open DataReader but I checked my code and I always close my data reader and connection.

I don’t know what steps I should take to solve this bug. Any help would be greatly appreciated. Thank You!

 public bool open() {
        //-- check if connection is closed
        if (this.dbconn.State == System.Data.ConnectionState.Closed) {
            try {
                this.dbconn.Open();
            }
            catch (Exception ex) {
                this.errorCode = (int)DatabaseErrorType.DBOpenFailed;
                this.errorMessage = System.Web.HttpUtility.HtmlEncode(ex.Message);
                throw ex;
            }
        }
        return true;
    }

/// <summary> closes connection object</summary>
    public bool close() {
        if (!(this.dbconn == null)) {
            if (!(this.dbconn.State == System.Data.ConnectionState.Closed)) {
                try {
                    this.dbconn.Close();
                }
                catch (Exception ex) {
                    this.errorCode = (int)DatabaseErrorType.DBCloseFailed;
                    this.errorMessage = System.Web.HttpUtility.HtmlEncode(ex.Message);
                    return false;
                }

            }
        }
        return true;
    }
        // GET MULTI Accounts
    public List<DTO.DTOAccount> GetAccounts(DTO.DTOAccount objAcc) {
        //-- reset error variables
        resetError();

        // make sure the connection is open
        if (this.open()) {

            SqlDataReader sqlReader = null;

            try {

                SqlCommand sqlProcedure = new SqlCommand("[dbo].[sp_Select_ONECARD_ACCOUNTS]", this.dbconn);
                sqlProcedure.CommandType = System.Data.CommandType.StoredProcedure;
                sqlProcedure.Parameters.Add(new SqlParameter("@ACCOUNT"             , objAcc.AccountId));
                sqlProcedure.Parameters.Add(new SqlParameter("@UDEF_4"              , objAcc.UDEF_4));

                ~~~~sqlReader = sqlProcedure.ExecuteReader();

                List<DTO.DTOAccount> Accounts = new List<DTO.DTOAccount>();
                // iterate through all values returned
                while (sqlReader.Read()) {
                    DTO.DTOAccount tmpAccount               = new ca.eyecode.onecard.DTO.DTOAccount();
                    tmpAccount.AccountId                    = (String)sqlReader["ACCOUNT"];
                    tmpAccount.Category                     = (String)sqlReader["CATEGORY"];
                    tmpAccount.Groups                       = (String)sqlReader["GROUPS"];
                    tmpAccount.Suffix                       = (String)sqlReader["SUFFIX"];
                    tmpAccount.UDEF_1                       = ((String)sqlReader["UDEF_1"]).Trim();
                    tmpAccount.UDEF_4                       = ((String)sqlReader["UDEF_4"]).Trim();
                    tmpAccount.FirstName                    = ((String)sqlReader["FNAME"]).Trim();
                    tmpAccount.LastName                     = ((String)sqlReader["LNAME"]).Trim();
                    tmpAccount.Picture                      = (sqlReader["PICTURE"] == DBNull.Value ? String.Empty : (String)sqlReader["PICTURE"]).Trim();
                    // add account items
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.ONEcardCash, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_1"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.Department, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_2"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.BookStore, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_3"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.TechBalance, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_4"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.Bonus1, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_5"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.MealPlanExtra, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_6"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.MealPlanDollars, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_7"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.AramarkCredit, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_8"])});
                    tmpAccount.AccountItems.Add (new DTO.DTOAccountItem() { Account= AccountType.AramarkEmployees, Balance= Convert.ToDouble((Decimal)sqlReader["BALANCE_9"])});
                    // Combine Totals to One Meal PLAN
                    tmpAccount.AccountItems[5].Balance += tmpAccount.AccountItems[6].Balance;
                    tmpAccount.AccountItems[5].Balance += tmpAccount.AccountItems[8].Balance;
                    tmpAccount.AccountItems[6].Balance = 0;
                    tmpAccount.AccountItems[8].Balance = 0;

                    Accounts.Add(tmpAccount);
                }
                return Accounts;
            }
            finally {
                try {
                if (sqlReader != null)  {
                    sqlReader.Close();
                }
                }
                catch {}
                this.close();
            }

        }
        return null;
    }

ERROR

 Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 4/19/2012 11:30:39 AM 
Event time (UTC): 4/19/2012 5:30:39 PM 
Event ID: 7715c17b872240829c3dfb562268998e 
Event sequence: 1253 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/997719702/Root-1-129793277036652335 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: 
    Machine name: 

Process information: 
    Process ID: 820 
    Process name: w3wp.exe 
    Account name: 

Exception information: 
    Exception type: InvalidOperationException 
    Exception message: There is already an open DataReader associated with this Command which must be closed first.
   at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at ca.eyecode.onecard.DAO.DAOAccount.GetAccounts(DTOAccount objAcc) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\DAO\DAOAccount.cs:line 47
   at ca.eyecode.onecard.BL.BLAccount.AccountsGet(DTOAccount objAcc) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\BL\BLAccount.cs:line 228
   at ca.eyecode.onecard.BL.BLAccount.AccountLogin(String CCID, String Password) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\BL\BLAccount.cs:line 171
   at ca.eyecode.onecard.BL.BLFacade.AccountLogin(String CCID, String Password) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\BL\BLFacade.cs:line 36
   at ca.eyecode.onecard.Controllers.HomeController.Index(String inpCCID, String inpPASS) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Controllers\HomeController.cs:line 77
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Request information: 
    Request URL: 
    Request path: / 
    User host address: 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: 

Thread information: 
    Thread ID: 9 
    Thread account name:  
    Is impersonating: False 
    Stack trace:    at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at ca.eyecode.onecard.DAO.DAOAccount.GetAccounts(DTOAccount objAcc) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\DAO\DAOAccount.cs:line 47
   at ca.eyecode.onecard.BL.BLAccount.AccountsGet(DTOAccount objAcc) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\BL\BLAccount.cs:line 228
   at ca.eyecode.onecard.BL.BLAccount.AccountLogin(String CCID, String Password) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\BL\BLAccount.cs:line 171
   at ca.eyecode.onecard.BL.BLFacade.AccountLogin(String CCID, String Password) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Models\ca.eyecode\onecard\BL\BLFacade.cs:line 36
   at ca.eyecode.onecard.Controllers.HomeController.Index(String inpCCID, String inpPASS) in C:\inetpub\wwwroot\ONEcard\OneAccount\OneAccount\Controllers\HomeController.cs:line 77
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
  • 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-02T15:44:50+00:00Added an answer on June 2, 2026 at 3:44 pm

    The issue was that I had a try finally block in my code. Within a handled exception, the associated finally block is guaranteed to be run. However, if the exception is unhandled, execution of the finally block is dependent on how the exception unwind operation is triggered. That, in turn, is dependent on how your computer is set up.

    To make sure the finally block is executed every time you can not omit the catch block. http://msdn.microsoft.com/en-us/library/zwc8s4fz(v=vs.100).aspx

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

Sidebar

Related Questions

I am developing a Quiz game application which is being developed completely but at
I've developed a nice rich application interface using Backbone.js where users can add objects
I have developed an iPhone application for a café. In the application you can
We provide a web application with a frontend completely developed in Adobe Flash. When
I have a web application developed in ASP.NET 2.0, deployed in a data center.
I have a web application developed with Spring 2.5. The application has numerous controllers,
We are having an application developed for BlackBerry - a pretty big one only.
I've got an application developed on top of DokuWiki. I'd like to provide a
I have an application(Developed using Adobe AIR) in which i have opened a port
I have an application developed in C++ in Visual Studio 2003 (Windows Forms application).

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.