|
|
1 semana atrás | |
|---|---|---|
| .. | ||
| Properties | 6 meses atrás | |
| Program.cs | 1 semana atrás | |
| README.md | 1 semana atrás | |
| SelfContained.csproj | 6 meses atrás | |
This project aims to test the Terminal.Gui library to create a simple self-contained single-file GUI application in C#, ensuring that all its features are available.
This example uses the modern Terminal.Gui application model:
ConfigurationManager.Enable (ConfigLocations.All);
IApplication app = Application.Create ();
app.Init ();
using ExampleWindow exampleWindow = new ();
string? userName = app.Run (exampleWindow) as string;
app.Dispose ();
Console.WriteLine ($@"Username: {userName}");
Key aspects of the modern model:
Application.Create() to create an IApplication instanceapp.Init() to initialize the applicationapp.Run(view) to run views with proper resource managementapp.Dispose() to clean up resources and restore the terminalAccepting event instead of legacy Accept evente.Handled = true in event handlers to prevent further processingWith Debug the .csproj is used and with Release the latest nuget package is used, either in Solution Configurations or in Profile Publish.
To publish the self-contained single file in Debug or Release mode, it is not necessary to select it in the Solution Configurations, just choose the Debug or Release configuration in the Publish Profile.
When executing the file directly from the self-contained single file and needing to debug it, it will be necessary to attach it to the debugger, just like any other standalone application. However, when trying to attach the file running on Linux or macOS to the debugger, it will issue the error "Failed to attach to process: Unknown Error: 0x80131c3c". This issue has already been reported on Developer Community. Maybe it would be a good idea to vote in favor of this fix because I think Visual Studio for macOS is going to be discontinued and we need this fix to remotely attach a process running on Linux or macOS to Windows 11.