-
Notifications
You must be signed in to change notification settings - Fork 666
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
Is there a reason why the DISABLE_XAML_GENERATED_MAIN does not work for x86 platforms? #7068
Comments
When you say it's not called, do you mean that the app doesn't start? Or that it's calling the generated one instead? Note that if you create your own Main by copying the generated one and then setting that constant, in the copy you need to remove these two lines; the second one will block breakpoints from working in the method: [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler", " 1.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
Hi Mike, Thank you for your answer. I was meaning that if I set a breakpoint on the first line of my Main method, the breakpoint is not fired. So as the app runs, I suppose that the auto generated code is called. I can also add that I did not copy the main from the auto generated code, but I created it manually as explained in the sample. Thank you, |
I modified my WinUI3 project by adding the DISABLE_XAML_GENERATED_MAIN and the creating the Program.cs. Everything is firing normally, but while the UI is being created the execution eventually stop, never on the same spot. I trace with F10 step by step and eventually it won't go to the next line, the cpu is zero, the code still answer to resize window, but the app is not displaying anything. Never seen such a thing in my entire life. How is it possible that a main thread will simply not continue to the next instruction and never the same one without any errors. I have many await on the main thread that are interrupted by other code running on the main thread. So the multi-threading is completely broken now. The scary part is that they never return to what they were doing. This is technically impossible, but with MS everything is possible. |
I just want to say that the WinUI3 single-instance sample project has a huge problem and that will make it useless for most people because everything useful will not work. Writable bitmap will never initialize with content and Webview2 will not start ever. The problematic lines of codes were right in the beginning. static async Task Main(string[] args) //This will break everything using COM I don't know why making the main an async Task would break everything, but it does. "await writeableBitmap.SetSourceAsync(filestream)" would hang and never complete and So the solution was to replace the Main function definition with "static int Main(string[] args)" |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Hello,
I have a WinUI3 Desktop application and I am working to make it single-instanced.
I am following this article: https://blogs.windows.com/windowsdeveloper/2022/01/28/making-the-app-single-instanced-part-3/.
The mechanism works fine, but I Noticed that if I change the solution platform from x64 to x86, the static Main method in the Program class is not called and the single instance is not possible. Is there a reason for that? Where am I doing wrong?
Here the vs project :
Thank you. Best regards,
The text was updated successfully, but these errors were encountered: