-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[regression/8.0.0-preview.4.8333] Crash using Pinvoke.SetParent to create Window as Child #17490
Comments
Same issue here with SetParent when I try .Net 8 RC1 |
I had the same problem when trying to update to .net 8 |
Any updates on this? I also have a similar problem and the company wants the .net8 improvements! |
Confirmed that this regressed between 8.0.0-preview.3.8149 and 8.0.0-preview.4.8333. #14517 seems sus. |
It looks like when you call var mainWindowHandle = (Application.Current.MainPage.Window.Handler.PlatformView as MauiWinUIWindow).GetWindowHandle();
var childWindowHandle = this.PlatformView.GetWindowHandle();
PInvoke.SetParent(new Windows.Win32.Foundation.HWND(childWindowHandle), new Windows.Win32.Foundation.HWND(mainWindowHandle)); The AppWindow is null. We switched over to using |
### Description of Change When opening a new WinUI window. If the user parents that to the current window `UI.Xaml.Window.AppWindow` will be null so we need to account for this. I've also added `Window.AppWindow` to our set of banned APIs since it doesn't have null safety. Our `GetAppWindow` API does so that should keep us in a safer place to not regress this issue. ### Issues Fixed Fixes #17490
@danielancines @lfmouradasilva @LAGAMARIB @rodirigos What does your scenario look like here where you're using SetParent? If you have a chance and can describe your scenarios here #20253 That would be very helpful to us. |
Description
I have an application using Pinvoke.SetParent from user32.dll to create an MDI window experience, it's working like a charm on .net 7 last version, but, when I try .net 8 RC1, I'm getting an error and application crashes.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/danielancines/Maui-SetParentError-dotnet8Rc1
Version with bug
8.0.0-preview.4.8333
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.0-preview.3.8149
Affected platforms
Windows
Affected platform versions
windows10.0.19041.0
Did you find any workaround?
No.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: