Closed RickStrahl closed 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @vitek-karas, @agocke, @vsadov See info in area-owners.md if you want to be subscribed.
Author: | RickStrahl |
---|---|
Assignees: | - |
Labels: | `area-Host`, `untriaged` |
Milestone: | - |
UI apps don't produce errors on the command line (Windows actually doesn't capture the stdout or stderr of these). That said, you should be able to find something in the event log hopefully.
There are two possibilities, it's failing before the runtime itself is started (in the host), or after the runtime started during loading of the managed code (before the user code is executed).
If it's the first case, you should be able to capture the host logs:
set COREHOST_TRACE=1
set COREHOST_TRACEFILE=host.txt
<repro the failure by running the app from some "Random" folder>
This should produce host.txt
in the current directory. If you scroll to the very end of this file it should show the error if it's from the host.
If it's failing after the runtime started, you should be able to run this under a debugger and catch the exception that way.
Yup i just found that out. In fact, I found the offender which is a file that was referenced in the startup folder without a fully qualified path and failed. The event log had the full stack trace that actually made finding this straight forward - once I actually remembered to look there.
For a desktop app that feels very unnatural. The silent failure too feels just wrong. I want to see it fail with even a hard stop over just silently failing. For a desktop app I'd expect a dialog. For a console app I'd expect to see some sort of console error message.
As it stands though this is resolved and... due to Operator Error on my part 😳
I do agree that silently failing is not ideal. Just curious, did the failure happen in managed code? (as fixing the error experience would look very different if it did or didn't)
If you are considering visual feedback on failures please keep automation in mind. We had to jump through a lot of hoops to prevent any system provided dialogs from appearing during automated tests as those dialogs tend to be blocking and thus block automation from proceeding. An environment variable to suppress potential dialogs would be nice, if you plan to add any dialogs.
@batzen - absolutely agree. The host will popup dialogs on some error conditions, but it does have an env. variable to disable this behavior: DOTNET_DISABLE_GUI_ERRORS=1
should disable that. If we were to add more (as per above) I'm pretty sure we would put it behind the same variable.
Description
I'm unable to launch a .NET 6.0 WPF desktop application from a folder other than the folder that contains the binary installation folder. Launching the EXE from a different folder with a path only does not work - the EXE silent fails and exits without running the application.
I added some logging code as the first line of the WPF application in
App.xaml.cs
that logs output to the log file. In the first startup in the installation folder you can see the log hitting. In the second - failed - startup the log never gets hit meaning the application never gets to the first line of user code (ie. it's not my app that's failing). There is no error message of any sort - the application just silently fails.The only way the application will run is if the application is launched from the installation/compilation folder. This means it has to be either launched out of the start folder, or if using a shortcut the shortcut has to provide a launch folder.
In the capture above the the launch from the registered
.websurge
shell extension which runs a shell command to thec:\Program Files\
installation folder does not work either because it can't set the start folder.Reproduction Steps
So I tried this with another WPF application created from scratch - and it behaves as expected. This problem appears to be specific to this particular application. However, I don't see anything that is wrong or would cause the application to fail to load. There are no external dependencies that could be missing.
There are however some 'refs' that include native components - specifically a
WebView2Loader.dll
.If necessary I can provide access to the repository to compile and run this application, but it is a private repo.
Expected behavior
Application should launch out of the startup folder without having to be launched from that folder.
If it fails as it appears to be - there should be some sort of message that provides more information on why it is failing.
Actual behavior
App fails silently.
Regression?
No response
Known Workarounds
No response
Configuration
This is a .NET 6.0 WPF Desktop application. Here's the full project file.
Other information
No response