|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Error with .Net Profider 1.5.4
Hi All
I am writing a application that works with the meta data of 3 types of databases M$ SQL Server, Oracle and Firebird. To keep things easy for myself i have decided to work with the interfaces of the objects like Idbconnection, idtransaction, IDbConnection ex... So all though i am using the database specific providers i extract the interfaces that they implement. This works perfect for M$ SQL Server and Oracle but on FireBird i get an error when trying to close the dbconnection and when i try to dispose of a Command object. Please remember that i am working with the interfaces of the objects. I don't have the exact error message now but will post it here later. The error message complains about something like "writing to stream not allowed" I use to get these error in Provider 1.5.3 aswell. I also know that the error message about disposing the command object was also discussed on the Yahoo Support groups about a month ago - Thought is was suppose to be fixed in 1.5.4...I might me missing something. Here is some code snippets. Private _DBConnection As IDbConnection Private _DB_Command As IDbCommand ..... Public Function CloseConnection() Try If Not IsNothing(_DBConnection) Then If _DBConnection.State = ConnectionState.Open Then _DBConnection.Close() End If End If Catch E As Exception 'Had to add this as the firebird connection throws error. End Try Protected Overrides Sub Finalize() Try _DB_Command.Dispose() Catch Ex As Exception 'Throw Ex 'Firebird gives an error when freeing the DBCommand - So just shut up for know. End Try MyBase.Finalize() End Sub End Function Thanks Wayne |
|
#2
|
|||
|
|||
|
Quote:
Huummmm ..... If you want to do that in the finalizer probably you will need to review GC.SuppressFinalize(); The call to Dispose will try to free the resources allocated for the command in the Firebird server but the socket used for communication is, more than probably, collected yet by the GC. I want to review some things arround this for future versions of the provider but for now it's in my todo list ![]() You will get faster answers if you send .net provider related questions to the developement list, you can subscribe to it here: http://lists.sourceforge.net/lists/...rd-net-provider |
|
#3
|
|||
|
|||
|
Quote:
Uh !! forget this one !! |
|
#4
|
|||
|
|||
|
Hi All (and Carlos)
Here is the exact error message that i get when closing the dbconnection. - This error does not happen everytime it is random. I have to repeat the same process about 10 times (open the app extract the meta data then close app) before this error occurs...So that makes me wonder whether it is not a .Net Garage Collector problem? An unhandled exception of type 'System.NotSupportedException' occurred in iis_cl.core.dll Additional information: Stream does not support writing. StackTrace: at System.IO.__Error.WriteNotSupported() at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count) at System.IO.BinaryWriter.Write(Int32 value) at FirebirdSql.Data.Firebird.Gds.GdsInetWriter.WriteInt(Int32 val) at FirebirdSql.Data.Firebird.Gds.GdsDbAttachment.Detach() at FirebirdSql.Data.Firebird.FbDbConnection.Disconnect() at FirebirdSql.Data.Firebird.FbConnection.Close() at IIS_CL.DB.DBSchema.CLS_DBSchema.CloseConnection() in C:\Documents and Settings\Wayne\My Documents\Visual Studio Projects\IIS_CL_CORE\Database\Database_Schema_Structures\CLS_DBSchema.vb |
|
#5
|
|||
|
|||
|
Quote:
I was thining in the call to the Dispose method of the command object in the Finalizer, sorry . Where is called the CloseConnection method ?? (seems that the networkstream/socket are invalid when closing the connection) |
|
#6
|
|||
|
|||
|
Quote:
The CloseConnection is a method that is part of class called CLS_DBSchema. This method get called by then CLS_DBSchema's finalize method. Protected Overrides Sub Finalize() CloseConnection() MyBase.Finalize() End Sub Close connection also get called by another class that reads data from this class. I hope i am doing enough checks before closing the connection. Here is the exact code. Public Function CloseConnection() Try If Not IsNothing(FDBConnection) Then If FDBConnection.State = ConnectionState.Open Then FDBConnection.Close() End If End If Catch E As Exception Throw End Try End Function Do i need to do more checks before closing the connection? Is it possible that the State is set to Open but it is actualy closed? |
|
#7
|
|||
|
|||
|
Quote:
I think the problem is that GAC has collected yet the socket on the finalizer (The FbConnection class has a call to GC.SupressFinalize in the constructor but it isn't in the inner class used for the connection). You will need to close the connection outside the Finalize method. (I'm doing some tests right now in this issue in the v1.7 sources for see if i can do anything for allow this) |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Error with .Net Profider 1.5.4 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|