incorrect Dispose function
See original GitHub issueHi,
the code that actually makes the disposing of an ExcelQueryFactory is never called because of this condition on the begining of the function
protected virtual void Dispose(bool disposing)
{
**if (!_disposed) // this is not ok, should be if (_disposed)
return;**
//this is never called because _disposed is always false
if (disposing)
{
if (_queryArgs != null && _queryArgs.PersistentConnection != null)
{
try
{
_queryArgs.PersistentConnection.Dispose();
_queryArgs.PersistentConnection = null;
}
catch (Exception ex)
{
_log.Error("Error disposing OleDbConnection", ex);
}
}
}
_queryArgs = null;
_disposed = true;
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:10
Top Results From Across the Web
Implement a Dispose method
In this article, learn to implement the Dispose method, ... IntPtr are considered invalid and how to actually free the handle.
Read more >c# - Why using Dispose as a normal method is bad?
it's totally fine to put into dispose any code an call it internally at any time if object state properly maintained. Correct me...
Read more >The Dispose(bool disposing) Pattern is Broken
In .NET, the relationship between Dispose() and finalizers is confusing. In this post, we take a look at the Dispose pattern, the snowball ......
Read more >fixed assets - dispose function error - context is incorrect
Created an asset transaction w/o invoice. Processed it with Movements/ Dispose - no issues there. However, status of context was off: Value: ...
Read more >c# - Dispose pattern without unmanaged objects
Your first approach is already wrong. The parent class implements the dispose pattern. Anything you descend from that must not mess with a ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It also leaves a locked file until the application using the add-in is closed. In my circumstance I was using it in a service on a thread, once I accessed the file to read it thew file remained locked event though the thread and class had been terminated. As the service is still running the lock is maintained, doesn’t release until the service is restarted.
Peter
Ah, sorry. I’ve had a lot going on in the last year. It’s been hard to get any time to work on this project 😢