Detecting resources not being released from com extension

J

J.P.

I've developed a com extension for explorer and another dll linked to
the com extension which provides the actual functionality. The
extension does nothing more than create an object and pass selected
files to the object for further processing. The problem I'm running
into is with a few cases resources do not seem to be properly
released. For example, I can remove all of the files in the given
folder where the shell extension was used but I cannot remove the
folder itself because it is still in use by some process. I'm having
trouble tracking down what's being left in memory, running or what
have you that is occupying the folder. My question is are there any
tools or methods I can use to track down what's not being released
under this scenario (a com shell extension and a dll all written in
c#)?

Thanks,
J.P.

P.S. I've tried monitoring a given folder with utilities like
SysInternal's FileMon, I'm not finding any useful information there
linking me back to the com extension.
 
J

J.P.

I've developed a com extension for explorer and another dll linked to
the com extension which provides the actual functionality. The
extension does nothing more than create an object and pass selected
files to the object for further processing. The problem I'm running
into is with a few cases resources do not seem to be properly
released. For example, I can remove all of the files in the given
folder where the shell extension was used but I cannot remove the
folder itself because it is still in use by some process. I'm having
trouble tracking down what's being left in memory, running or what
have you that is occupying the folder. My question is are there any
tools or methods I can use to track down what's not being released
under this scenario (a com shell extension and a dll all written in
c#)?

Thanks,
J.P.

P.S. I've tried monitoring a given folder with utilities like
SysInternal's FileMon, I'm not finding any useful information there
linking me back to the com extension.

After further digging I have found the cause of the problem. The issue
has only occurred with objects that create and use the SaveFileDialog,
to confirm this I commented the SaveFileDialog code in one of the
offending objects and tested it multiple times to make sure the
directory could in fact be deleted. The problem has not happened
since. I would prefer to keep the SaveFileDialog, so what I've tried
at this point is calling the .Dispose() member, assigning null to the
object and calling GC.Collect(). This does not solve the problem. Here
is the actual code being executed:

SaveFileDialog sfd = new SaveFileDialog();

sfd.InitialDirectory = m_Directory;
sfd.Title = "Document Save";
sfd.Filter = "*.pdf|*.pdf";
sfd.FileName = "combined_document.pdf";


if (sfd.ShowDialog(this) != DialogResult.OK) {
sfd = null;
GC.Collect();
this.Close();
return;
}

try {
if (File.Exists(sfd.FileName)) {
File.Delete(sfd.FileName);
}
}
catch (Exception ex) {
ShowError(ex.Message, "PdfTool: Error removing
existing file");
this.Close();
return;
}

m_outFile = sfd.FileName;
sfd.Dispose();
sfd = null;
GC.Collect();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top