-
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
Setting ShowInTaskbar to false causes the form to close automatically (Abnormal exit). #6421
Comments
This is odd because in my program it works just fine (even when using 7.0.0-dev runtime) 🤔 (And I change it in a Timer when the application's own settings change from displaying the icon in taskbar to tray or to both). |
Did you use Win7 or Win11? I am running on Win10 system (21H2) with .NET 6.0 (Version: 6.0.1). I just used a clean Win10 computer for testing, and it was running on .net 5.0 (Version: 5.0.0, No patch), and the same problem occurred. |
I use Windows 11 on my old computer (that had 11 since it was in preview), and my newer one and it seems to work fine with 6.0.0, 6.0.1, and 7.0.0-dev. |
I just used Win11 for testing. I used the test code above. Found the same problem. I am not sure if this problem can be avoided by other codes in your program. |
I can confirm this problem using Win10 21H2, on .NET 6.0.1 but not Win10 21H2 .NET 6.0.0. |
Odd I now run into this issue now with manually built runtime running at the tip of branch main. |
I think it could be that I hide the form the first thing right on the load event on my forms program causing it to terminate ironically right after it loads TerraFX.Interop.Windows 😄. Yes ironically it uses this API when the user configures for the program to not display it in the Taskbar. |
Add test app here: TestApp6421.zip |
I will be testing the changes in #6477 to ensure my program now properly runs the way it was before I installed the 6.0.1 servicing (however it will be the changes in the main branch as I was testing it with an updated zlib impl on the base runtime I was already making that was proposed into .NET 7). |
So, was the cause of this found as I use this on my main program by default on startup which seems to cause it to instantly close in .NET 7. I got reports that a user who done a clone and did a clean build in .NET 6's latest 6.0.2 patch seems to work fine on their end (or so it looked like it did). |
I have run the provided sample on Win11 (10.0.22000 Build 22000), and confirmed the behaviour is consistent as far as .NET Framework 4.7.2 and all the way up to .NET 7 Preview1. @Olina-Zhang would you be able to test 6421.zip on different versions of Windows 10 and see if there are any differences in behaviours? Thank you. |
@RussKie we have tested the sample project on 9 different Win10 OSs(20H2, 20H1, 19H1, 19H2, RS5, RS4, RS3, RS2, RS1), they are all the same result when target to .NET 7.0 or .NET 6.0 or .NET Framework 4.7.2 or .NET Framework 4.8. |
What is the result with running it in 8, 8.1 and 7 with .NET 7.0? |
@AraHaan It's the same result in 8.1 and 7 with .NET 7.0. |
@John-Qiao Do you mean the test result is OK, or it's Failed? I just re-tested on my computer. It does not work with .net 6.0. If you need, I can provide the version number of the operating system and the video to you. |
@roland5572 I mean the issue is still reproduced in that environments: click the button in new form will close the new form automatically. |
Hmm I wonder if it's due to the implementation of the property itself, if only I could add the Windows Forms code as a local project reference just so I can set breakpoints on it in my code to know for sure if that property is what causes my program to randomly terminate. Then if so, I will need to figure out ways of doing the same thing without terminating any forms (perhaps have the runtime create a dummy parent form for a form that is not visible so then it makes it not applicable to have an taskbar entry. However what about cases of programs with forms where the parent form is both shown in tray & taskbar and it's designed to show the settings and about forms without either one as that button brings it all to focus anyway and the parent form can be configured at any time to not show the tray or not show in taskbar as well (as 3 options in settings total) with a timer in the parent that reads the saved settings? |
Try this https://github.com/dotnet/winforms/blob/main/docs/debugging.md. |
Too bad we cant debug using the sources downloaded from sourcelink to set breakpoints so we can debug the actual binaries that get installed from the stable builds of the sdk. |
You should be able to with the help of function breakpoints
https://docs.microsoft.com/visualstudio/debugger/using-breakpoints#BKMK_Set_a_breakpoint_in_a_source_file
|
You can debug .net WinForms.
|
If I am doing all of that work, why not publish the projects that allow one to do the same type of integration tests that this repo uses so they can test their own code too? 😄 Talking about publish as in to a nuget package. |
@AraHaan Maybe the integration tests are not in the current roadmap. This method is currently the most effective. |
If you have any proposals, you'd like to discuss, or have any questions - please start a new discussion thread. |
Verified this issue on .NET 7.0.100-preview.4.22227.3, issue was fixed, click the button in new form will not close the new form automatically. TestApp4621.zip |
you mean preview.5.22227.3? |
@AraHaan Yesterday, I installed Release/7.0.1xx-preview4(7.0.x Runtime) from https://github.com/dotnet/installer and test this. |
I see, I been actually looking for the link to download only the daily quality Windows Desktop and ASP.NET Runtimes as it seems that the sdk installer seems to always not install the exact matching version suffix builds. |
@AraHaan I don't think there's a way of doing this (outside the team). @kant2002 has created a service that can help determining what versions the installer has, you can find it here: https://kant2002.github.io/dotnet-installer-viewer/. |
Wait why is System.Private.Winforms preview 4 still? Sad it don't add an download link that links to the azureblobstorage location of them either. |
Setting ShowInTaskbar to false causes the form to close automatically (Abnormal exit).
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form
Test Code:
.NET 6.0 (Version: 6.0.1)(This problem also appears in .net framework 4.8)
Win10 system (21H2).
Steps to reproduce:
The text was updated successfully, but these errors were encountered: