-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
WPF Blazor cannot be started at boot. Error: There is no content at #19359
Comments
Hi @JiuLing-zhang , this could be due to the 'current directory' of the app being the However, the BlazorWebView control does try to force loading its content from wherever the app is on disk so the current directory shouldn't matter. This is the code that does that: https://github.com/dotnet/maui/blob/main/src/BlazorWebView/src/Wpf/BlazorWebView.cs#L258 Can you confirm that all of the app's file are actually on disk in the expected location? That is, go to wherever the published EXE is on disk and check that the |
Hi @Eilon , all documents are complete. I guess it maybe about the path, because the same problem occurred when I started it with cmd.
|
@JiuLing-zhang thank you for confirming, this does look like a bug. Could you try adding this line at the start of your app's Environment.CurrentDirectory = Path.GetDirectoryName(typeof(Program).Assembly.Location); If that works, it should be a good workaround for you to use until we can investigate further. |
Hi @Eilon , This path is the real path during build, it won't work on other computers. My project type of WPF. // use App, not Program
Path.GetDirectoryName(typeof(App).Assembly.Location); I temporarily solved the problem by doing the following: Environment.CurrentDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); Thanks. |
I made a mistake, |
@JiuLing-zhang oh interesting. Perhaps because of the publish/ReadyToRun, that causes the assembly to no longer exist in its original form, so that ends up being null. That is probably the root cause of this issue. I think that gives us enough info to try to come up with a more permanent solution. Does the workaround always work in your case? |
@Eilon I changed some computers for test and it works. Environment.CurrentDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); |
I am also running into this issue when publishing a single-file Winforms app with Blazor in Webview. The issue does not occur for a normal (not single-file) build. |
@Mr-Technician does the CurrentDirectory workaround above work for you? It's likely the same issue. |
@Eilon This is my current solution: blazorWebView1.HostPage = Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "wwwroot\\index.html"); It is essentially the same as setting |
This was fixed by #21750 |
Description
I have created a WPF Blazor via the MS sample , but it doesn't be started at boot.
Microsoft.AspNetCore.Components.WebView.Wpf is used in the example, which points to this repository in nuget.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/JiuLing-zhang/TestAutostart.git
Version with bug
7.0.101
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 11
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: