.NET version
.NET 8
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Haven't tried on earlier, but also broken on .NET 9
Issue description
The container of an AxHost never gets garbage collected. We originally discovered this while investigating a GDI Object leak, which is a manifestation of the container never getting collected.
The "solution" in Issue 13499 did not work.
Steps to reproduce
The attached projects demonstrate the issue by tracking when the container is constructed, disposed and finalized. The three projects are:
ActiveXControl_MFC - an MFC project that builds an ocx; the post-build step registers it (requires Visual Studio 2022 run as admin) and creates an interop assembly
AxHostContainer - a .NET 8 project that contains the AxHost
AxHostContainer_Framework48 - a .NET Framework 4.8 project that contains the AxHost
The AxHostContainer projects are identical, except for the targeted .NET platform.
Running AxHostContainer apps:
The AxHostContainer apps effectively execute four cases, two on .NET 8 and the same two repeated on .NET Framework 4.8. Each of the four cases open and close a Form multiple times.
Without AxHost With AxHost
.NET 8 + x
.NET FW + +
Only the .NET 8 With AxHost case exhibits the bad behavior where the finalizers fail to execute.
AxHostLeak.zip
.NET version
.NET 8
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Haven't tried on earlier, but also broken on .NET 9
Issue description
The container of an AxHost never gets garbage collected. We originally discovered this while investigating a GDI Object leak, which is a manifestation of the container never getting collected.
The "solution" in Issue 13499 did not work.
Steps to reproduce
The attached projects demonstrate the issue by tracking when the container is constructed, disposed and finalized. The three projects are:
ActiveXControl_MFC - an MFC project that builds an ocx; the post-build step registers it (requires Visual Studio 2022 run as admin) and creates an interop assembly
AxHostContainer - a .NET 8 project that contains the AxHost
AxHostContainer_Framework48 - a .NET Framework 4.8 project that contains the AxHost
The AxHostContainer projects are identical, except for the targeted .NET platform.
Running AxHostContainer apps:
The AxHostContainer apps effectively execute four cases, two on .NET 8 and the same two repeated on .NET Framework 4.8. Each of the four cases open and close a Form multiple times.
Only the .NET 8 With AxHost case exhibits the bad behavior where the finalizers fail to execute.
AxHostLeak.zip