Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 23rd, 2004, 06:16 AM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
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

Reply With Quote
  #2  
Old June 23rd, 2004, 09:22 AM
carlosga carlosga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 13 carlosga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by WayneB
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


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

Reply With Quote
  #3  
Old June 23rd, 2004, 10:13 AM
carlosga carlosga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 13 carlosga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by carlosga
Huummmm ..... If you want to do that in the finalizer probably you will need to review

GC.SuppressFinalize();


Uh !! forget this one !!

Reply With Quote
  #4  
Old June 23rd, 2004, 01:37 PM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
Angry

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

Reply With Quote
  #5  
Old June 23rd, 2004, 01:46 PM
carlosga carlosga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 13 carlosga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by WayneB
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?


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)

Reply With Quote
  #6  
Old June 23rd, 2004, 01:56 PM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
Quote:
Originally Posted by carlosga
Where is called the CloseConnection method ?? (seems that the networkstream/socket are invalid when closing the connection)


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?

Reply With Quote
  #7  
Old June 23rd, 2004, 02:29 PM
carlosga carlosga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 13 carlosga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by WayneB
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

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?


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)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Error with .Net Profider 1.5.4


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT