COleControlSite re-enter destructor
See original GitHub issue.NET version
.NET8 preview6, and daily build, and build with latest code
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
It works fine before .NET8
Issue description
See following call stack, COleControlSite::~COleControlSite is called again, it makes app crash.
Steps to reproduce
I don’t know OLE, it’s not easy for me to make a test app, but I compare .NET8 and .NET7 source code. It may be helpful for you to understand the problem.
In .NET8, the second destructor is called from this line: https://github.com/dotnet/winforms/blob/e9a35997645b440b605f0d975305e313a6808883/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs#L1705
Before .NET8, this line doesn’t call destructor again: https://github.com/dotnet/winforms/blob/32a4f45583a44acc811da8c452d4a5f673342893/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs#L1918
So I guess it’s probably related to @JeremyKuhne 's https://github.com/dotnet/winforms/pull/8420
Issue Analytics
- State:
- Created 2 months ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
@panxn I messed up with the ref counting when I reworked this.
We did major refactoring here to get us closer to being able to enable Ahead-Of-Time (AOT) compilation and trimming for WinForms. We didn’t get all the way there for .NET 8, but we’re hoping to finish in .NET 9.
Please tag me directly on any other issues you might encounter, and I’ll look at them right away.
Thank you! It works for me now.