-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Labels
Milestone
Description
Description
Using statements do not properly dispose of System.Management.ManagementBaseObject or System.Management.ManagementObject due to both classes defining new Dispose() methods that hide the base class method with new rather than overriding the virtual void Dispose(bool disposing) from System.ComponentModel.Component.
Reproduction Steps
using System.Management;
using (var mo = new ManagementObject()) {
} // step through with a debugger and observe that neither ManagementObject.Dispose() nor ManagementBaseObject.Dispose() are called, but only Componnet.Dispose()Expected behavior
ManagementObject and ManagementBaseObject have disposal code called.
Actual behavior
Only Component has its disposal code called.
Regression?
No
Known Workarounds
Avoid using using statements with these classes and instead use a try/finally.
Configuration
.NET 9
Windows 10 Enterprise
x64
Other information
Reactions are currently unavailable