question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

incorrect Dispose function

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:10

github_iconTop GitHub Comments

2reactions
buda56commented, Aug 9, 2016

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

0reactions
mrworkmancommented, Dec 5, 2019

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 😢

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found