-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net 8 upgrade is not able send WM_DESTROY message to ActiveXControl from interop assembly #12551
.Net 8 upgrade is not able send WM_DESTROY message to ActiveXControl from interop assembly #12551
Comments
We still had a number of potential and actual overflow scenarios. In order to make this more resilient, move SendMessage, PostMessage, and Get/SetWindowLong from IntPtr to nint. This also makes things slightly faster as we aren't creating IntPtr structs and invoking the cast methods on it. Note that IntPtr implicitly converts to nint. I've removed most of the actual IntPtr usages. I've also removed most of the HandleRef overloads and vetted the callers to do the right thing in regards to avoiding finalizer issues. There is more we can do here, but this is a big first step. Also clean up DateTimePicker and move SYSTEMTIME converters to SYSTEMTIME. I've tried to remove all (IntPtr) casts in SendMessage calls.
Reopening for pending work to add test + servicing |
@lonitra / @JeremyKuhne , do you have an expected date for patching .NET 8.0 with this change? We urgently need this fix in .NET 8, as our product release depends on it and this issue is affecting our product quality. |
@Sachin-NI we need to get approval for it and validate the fix. If it is approved, it would be in February most likely. |
@Sachin-NI Could you provide a sample solution with the custom |
@Syareel-Sukeri, |
@LeafShi1 - please prepare backport PRs to release/8.0 and 9.0, when Syareel signs off on the fix, include both PRs attached to this issue. @JeremyKuhne will add tests to the servicing PRs later. |
@lonitra @Tanya-Solyanik There is an exception currently blocking the verification process when using binaries built from main branch of Winforms repo to verify. I will continue to verify again when all changes flow into SDK. |
@Syareel-Sukeri System.Private.Windows.GdiPlus is a new assembly added recently and should produce when building from main. Are you getting this exception if that dll is included? |
@lonitra Yes, I encounter the exception regardless of whether the System.Private.Windows.GdiPlus.dll is included. |
@lonitra @Tanya-Solyanik Reverted to the previous branch before System.Private.Windows.GdiPlus.dll was created and manually applied the code changes in AxHost.cs as recommended by Tanya. Built the branch and placed the generated DLLs in the .NET 10.0.100-alpha.1.24617.8 SDK. Verified the issue, and the parent control now correctly sends the WM_DESTROY message to the child controls during the disposal of ActiveX child controls. |
.NET version
net8.0-windows
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Issue description
Parent container control is not sending WM_DESTROY message to the child control while disposing the ActiveX child controls and thus our custom onDestroy method never get called.
From my call stack, I could pin point the cause of this issue to be this change by @JeremyKuhne in
DetachAndForward
Method inAxHost.cs
.The issue is that isHandleCreated need to be stored before calling
DetachWindow()
method in theDetachAndForward
method as we were doing earlier, becauseisHandleCreated
value will always get set to false after callingDetachWindow
method so the code inside the if block will never be executed in any case.New Code after the changes done in this PR:
Old Code before this PR:
As we are going to release our product with .net 8, We need the fix to be also present in .net 8.
Steps to reproduce
OR
Create a Parent Container Control:
Add ActiveX Child Controls:
OnDestroy
methods that should be called when they are destroyed.Implement Custom
OnDestroy
Method:OnDestroy
method that performs specific cleanup tasks.WM_DESTROY
message using theMESSAGE_HANDLER
macro.Trigger Disposal of Child Controls:
Observe Message Handling:
WM_DESTROY
message is being sent to the child controls.Verify
OnDestroy
Method Execution:OnDestroy
method in the child controls is being called.The text was updated successfully, but these errors were encountered: