From: Thomas <ja...@ma...> - 2003-12-19 21:25:05
|
Hi Carlos Now I have re-created the problem. This log line:=20 Console.WriteLine(eb.Message + " - " + eb.Source + " - " + eb.StackTrace = + " - " + eb.InnerException); prints this message: 21:54:56.140 - Message: Object reference not set to an instance of an = object. - Stacktrace: at = FirebirdSql.Data.Firebird.Gds.GdsTransaction.BeginTransaction() at = FirebirdSql.Data.Firebird.FbTransaction.BeginTransaction() at = FirebirdSql.Data.Firebird.FbConnection.BeginTransaction() at = Tricon.Funki.PDBServer.DataAccessLogicComponents.LoadStatements.loadAllSc= aleHavePipe() in = c:\vss\funki\pdbserver\tricon.funki.pdbserver\dataaccesslogiccomponents\l= oadstatements.cs:line 2509 - Source: FirebirdSql.Data.Firebird - = InnerException: (The InnerException is empty.) In this test case, the same code runs 288 times. In loop 289 the exception arised. My code: (loadAllScaleHavePipe() failed in loop no. 289.) public Hashtable loadAllScaleHavePipe() { ScaleHavePipe scalehavepipe =3D null; Hashtable HT =3D new Hashtable(); =20 myConnection =3D Connection.Instance.MyConnection; mySelectQuery =3D "SELECT * FROM scalehavepipe"; try { =20 transaction =3D myConnection.BeginTransaction(); <---- ERROR ? myCommand =3D new FbCommand(mySelectQuery, myConnection, = transaction); =20 myReader =3D myCommand.ExecuteReader(); =20 while (myReader.Read()) { scalehavepipe =3D new = ScaleHavePipe((int)myReader["id"],(int)myReader["scaletype"], (int)myReader["scale_id"],(int)myReader["pipe_id"]); HT.Add(scalehavepipe.Id, scalehavepipe); }//while myReader.Close();=20 transaction.Commit(); } catch(Exception eb) { =20 Console.WriteLine(eb.Message + " - " + eb.Source + " - " + = eb.StackTrace + " - " + eb.InnerException); BusinessComponents.LogToFile.Instance.logALineToFile(eb.Message + " = - " + eb.Source + " - " + eb.StackTrace + " - " + = eb.InnerException,true); if (eb is FbException) { FbException myException =3D (FbException)eb; =20 BusinessComponents.LogToFile.Instance.logALineToFile("This is a = FbException: Message: "+myException.Message + " - Stacktrace: " + = myException.StackTrace + " - Source: " +myException.Source + " - = InnerException:" + myException.InnerException + " - ErrorCode: " + = myException.ErrorCode,true); Console.WriteLine("This is a FbException: Message: = "+myException.Message + " - Stacktrace: " + myException.StackTrace + " - = Source: " +myException.Source + " - InnerException:" + = myException.InnerException + " - ErrorCode: " + myException.ErrorCode); if (myException.Errors.Count =3D=3D 0) { = BusinessComponents.LogToFile.Instance.logALineToFile("myException.Errors.= Count is 0 ",true); } for (int i=3D0; i < myException.Errors.Count; i++) { =20 BusinessComponents.LogToFile.Instance.logALineToFile("Index #" + i = + "\n" +"Error: " + myException.Errors[i].ToString() + "\n",true); =20 } =20 } else { =20 BusinessComponents.LogToFile.Instance.logALineToFile("Message: = "+eb.Message + " - Stacktrace: " + eb.StackTrace + " - Source: " = +eb.Source + " - InnerException:" + eb.InnerException,true); Console.WriteLine("Message: "+eb.Message + " - Stacktrace: " + = eb.StackTrace + " - Source: " +eb.Source + " - InnerException:" + = eb.InnerException); } Connection.Instance.closeConnection(); Connection.Instance.openConnection(); throw eb; }//try/catch return HT; }//loadAllScaleHavePipe =20 =20 =20 =20 public FbConnection MyConnection { get { =20 try { if (this.connectionCounter > 500) { if (this.myConnection !=3D null) { myConnection.Dispose(); myConnection =3D new FbConnection(myConnectionString); openConnection(); this.connectionCounter =3D 0; }//if }//if =20 else { =20 if (this.myConnection !=3D null) { closeConnection(); }//if openConnection(); this.connectionCounter =3D this.connectionCounter+1; }//else =20 }//try catch (Exception eb) { =20 =20 if (eb is FbException) { FbException myException =3D (FbException)eb; =20 BusinessComponents.LogToFile.Instance.logALineToFile("This is a = FbException: Message: "+myException.Message + " - Stacktrace: " + = myException.StackTrace + " - Source: " +myException.Source + " - = InnerException:" + myException.InnerException + " - ErrorCode: " + = myException.ErrorCode,true); Console.WriteLine("This is a FbException: Message: = "+myException.Message + " - Stacktrace: " + myException.StackTrace + " - = Source: " +myException.Source + " - InnerException:" + = myException.InnerException + " - ErrorCode: " + myException.ErrorCode); if (myException.Errors.Count =3D=3D 0) { = BusinessComponents.LogToFile.Instance.logALineToFile("myException.Errors.= Count is 0 ",true); } for (int i=3D0; i < myException.Errors.Count; i++) { =20 BusinessComponents.LogToFile.Instance.logALineToFile("Index #" = + i + "\n" +"Error: " + myException.Errors[i].ToString() + "\n",true); = =20 } =20 } else { =20 BusinessComponents.LogToFile.Instance.logALineToFile("Message: = "+eb.Message + " - Stacktrace: " + eb.StackTrace + " - Source: " = +eb.Source + " - InnerException:" + eb.InnerException,true); Console.WriteLine("Message: "+eb.Message + " - Stacktrace: " + = eb.StackTrace + " - Source: " +eb.Source + " - InnerException:" + = eb.InnerException); } =20 }//try/catch return this.myConnection; }//get =20 }//property myConnection I cannot see why a "Object reference not set to an instance of an = object" should come after 288 loops. Thanks Regards Thomas -------------------------------------------------------------------------= -------------------------------------------------------------------------= -------------------------------------------------------- Now and then we get an exception in "BeginTrancaction". When I call BeginTransaction(), then I get this error: at FirebirdSql.Data.Firebird.Gds.GdsTransaction.BeginTransaction() at FirebirdSql.Data.Firebird.FbTransaction.BeginTransaction() at FirebirdSql.Data.Firebird.FbConnection.BeginTransaction() (That is all the info that I get) Some times the exception arise after 5 minutes, and some times the = exception arise after 30 hours. Very very random. It is very hard to re-create the error, but it is 100% sure that the = error arise at some point. In my program, I call "myConnection.BeginTransaction()" once every 3 = second. (Many hours). We use: WinXP SP1 FirebirdSql.Data.Firebird.dll v. 1.5.1437.22333 (.NET 1.1) Firebird-1.5.0.4027-RC7, running af Super Server. Microsoft .NET Framework 1.1 v. 1.1.4322 Hope that you can help me with this problem. Thanks Regards Thomas /// Code snip////// (It is impossible to send the full code) My Connection Class that is a singleton: ........................ private FbConnection myConnection; public static Connection Instance { get { =20 if(instance =3D=3D null) { instance =3D new Connection(); =20 }//if return instance; }//get property }//property get instance of Connection =20 //constructor private Connection() { try { myConnectionString =3D getURLToDB(); myConnection =3D new FbConnection(myConnectionString); =20 openConnection(); }//try catch (Exception ex) { string t =3D ex.Message; string t2 =3D ex.StackTrace; = BusinessComponents.LogToFile.Instance.logALineToFile(ex.ToString(),true);= }//try/catch }//constructor =20 =20 =20 public bool updateTransaction(string myUpdateQuery) { try { myConnection =3D MyConnection; transaction =3D myConnection.BeginTransaction(); myCommandOne =3D new FbCommand(myUpdateQuery, myConnection, = transaction);=20 myCommandOne.ExecuteNonQuery(); transaction.Commit(); myCommandOne.Dispose(); } catch(Exception eb) { =20 =20 = BusinessComponents.LogToFile.Instance.logALineToFile(eb.StackTrace,true);= BusinessComponents.LogToFile.Instance.logALineToFile("This = SQL-statement was not saved in the database: " + myUpdateQuery,false); string t =3D eb.StackTrace; transaction.Rollback(); transaction.Dispose(); closeConnection(); openConnection(); throw eb; }//try/catch return true; }//updateTransaction =20 =20 =20 public void closeConnection() { try { if (myConnection.State !=3D System.Data.ConnectionState.Closed) { myConnection.Close(); =20 }//if }//try catch (Exception ex) { =20 = BusinessComponents.LogToFile.Instance.logALineToFile(ex.ToString(),true);= =20 Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); }//try/catch }//closeConnection =20 =20 public void openConnection() { try { if (myConnection.State !=3D System.Data.ConnectionState.Open) { myConnection.Open(); }//if }//try catch(Exception ex) { =20 = BusinessComponents.LogToFile.Instance.logALineToFile(ex.ToString(),true);= =20 Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); }//try/catch }//openConnection =20 =20 public FbConnection MyConnection { get { =20 try { if (this.connectionCounter > 500) { if (this.myConnection !=3D null) { myConnection.Dispose(); myConnection =3D new FbConnection(myConnectionString); openConnection(); this.connectionCounter =3D 0; }//if }//if =20 else { =20 if (this.myConnection !=3D null) { closeConnection(); }//if openConnection(); this.connectionCounter =3D this.connectionCounter+1; }//else =20 }//try catch (Exception ex) { =20 = BusinessComponents.LogToFile.Instance.logALineToFile(ex.ToString(),true);= =20 }//try/catch return this.myConnection; }//get =20 }//property myConnection =20 =20 =20 |