Hi,
a few years ago I've created an adapter wrapper, which is usually used to pass an adapter between application modules (if neccessary). It works correctly, but today, I've found a problem with disposing this object. Probably it is connected with npgsql driver upgrade which we've made a few weeks ago. The biggest problem is that exception occures randomly.
I'm wondering whether my adapter wrapper dispose method is correct according to llblgen guidlines.
private bool isDisposed = false;
~ApCDBTransaction()
{
Dispose();
}
public void Dispose()
{
lock (this)
{
if (this.isDisposed == false)
{
this.isDisposed = true;
Rollback();
this.adapter.CloseConnection();
this.adapter.Dispose();
}
}
}
I'm wondering, whether the close connection is necessary. Does the Dispose method on the llglben adapter object always invoke the CloseConnection method on the database driver or does it depend on some other mehinisms, configuration, etc. ? Can I safely remove the this.adapter.CloseConnection(); line?
Unhandled exception has happend: Cannot access a disposed object.
Object name: 'NpgsqlConnection'.;Cannot access a disposed object.
Object name: 'NpgsqlConnection'.StackTrace: at Npgsql.NpgsqlConnection.CheckNotDisposed() in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlConnection.cs:line 926
at Npgsql.NpgsqlConnection.get_FullState() in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlConnection.cs:line 386
at Npgsql.NpgsqlConnection.get_State() in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlConnection.cs:line 406
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CloseConnection() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 927
at Implementation.LLBLGen.Dependent.Adapters.ApCDBTransaction.Dispose()
Best Regards,
MiloszeS