none
Is anything wrong with these code RRS feed

  • Question

  • Our web server logged some run time error---accessViolationException errors.  The following code was written by somebody else for a .net 2.0 windows version which was then re-used for the web app. I suspected something wrong with it that cause the above run time error. Please help me figure it out. Thanks in advance.

     

    public sealed class DBConnection : IDisposable

    {

            OracleConnection mConn;

            OracleTransaction trx;

            public DBConnection()

            {

               

               

            }

     

            ~DBConnection()

            {

               if (this.mConn != null)

                {

                    mConn.Dispose();

                    mConn = null;

                }

               

            }

     

            public void Dispose()

            {

              

                if (mConn != null)

                {

                    mConn.Dispose();

                    mConn = null;

                }

                if (trx != null)

                    trx.Dispose();

              

            }

         

          // Other methods goes here…

           

    }

     

     

    public class myDataManager

                : System.ComponentModel.Component

        {

              System.ComponentModel.Container components = null;

                DBConnection dConn;

                apDataSet mDataSet;

                 

                public myDataManager(System.ComponentModel.IContainer container)

                {

                      container.Add(this);

                      InitializeComponent();

                }

               

               

                public myDataManager ()

                {

                      InitializeComponent();

                }

               

     

            ~ myDataManager()

            {

                if (dConn != null)

                {

                    dConn.Dispose();

                    dConn = null;

                }

            }

     

          protected override void Dispose( bool disposing )

          {

                if( disposing )

                {

                      if(components != null)

                            components.Dispose();

                      if(mDataSet!=null)

                                  mDataSet.Dispose();

                      if (dConn != null)

                      {

                        dConn.Dispose();

                        dConn = null;

                       }

                }

                      base.Dispose( disposing );

          }

         

    // Other methods goes here…

     

    Monday, May 19, 2008 12:46 PM

Answers

  • See if it helps by removing the finalizers, you don't need them as your classes don't use unmanaged resources.
    Monday, May 19, 2008 6:03 PM

All replies

  • See if it helps by removing the finalizers, you don't need them as your classes don't use unmanaged resources.
    Monday, May 19, 2008 6:03 PM
  • how do you identify manged resources and unmanaged resources? I mean does the connection to db hold unmanaged resources or not? how about command object and dataAdapter object?

    Friday, May 23, 2008 1:08 PM