DIDiskQuotaUser leaking file handles
I made a application to check the quota space checking application its 开发者_运维问答done like this
DIDiskQuotaUser QuotaInfo = null;
try
{
QuotaInfo = this.gDiskQuotaControl.FindUser(SAMUser);
}
catch
{
QuotaInfo = null;
}
Defenition of FindUser
[DispId(1610743828)]
public virtual DIDiskQuotaUser FindUser(string LogonName);
Comes from:
[TypeLibType(2)]
[ComSourceInterfaces("DiskQuotaTypeLibrary.DIDiskQuotaControlEvents")]
[Guid("7988B571-EC89-11CF-9C00-00AA00A14F56")]
[ClassInterface(0)]
public class DiskQuotaControlClass : DIDiskQuotaControl, DiskQuotaControl, DIDiskQuotaControlEvents_Event, IDiskQuotaControlEvents, DIDiskQuotaUser, IEnumerable
Problem is that the loop is leaking file handles on the server im checking, and i cant see any way to dispose te return from FindUser
I'd try calling Marshal.FinalReleaseComObject on the object. That should be the equivalent of calling Release on the COM object until its reference count is zero, which should dispose of the object and release its handle.
精彩评论