blazor+winforms start failed with FileNotFoundException
wu-yafeng opened this issue · 2 comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have a very simple blazor + winform application. When I publish the project and run on my local computer, It works fine. But a error was occured while I run application on my windows server . (The message box was shown:
system info:
Microsoft Windows Server 2022 Datacenter 10.0.20348 暂缺 Build 20348
AMD64 Family 23 Model 49 Stepping 0 AuthenticAMD ~2595 Mhz
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new MainWindow());
}
}
public partial class MainWindow : Form
{
public MainWindow()
{
InitializeComponent();
var services = new ServiceCollection();
services.AddFluentUIComponents();
services.AddBlazorWebViewDeveloperTools();
services.AddWindowsFormsBlazorWebView();
services.AddHttpClient();
blazorWebView1.HostPage = "wwwroot\\index.html"; // once I remove this line, application start with no error!
blazorWebView1.Services = services.BuildServiceProvider();
blazorWebView1.RootComponents.Add<App>("#app");
}
}
my App.razor:
<h1>Hello World</h1>
my index.html
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WinFormsBlazor</title>
<base href="/" />
<link href="css/app.css" rel="stylesheet" />
<link href="_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.bundle.scp.css" rel="stylesheet" />
</head>
<body>
<div id="app">启动中...</div>
<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js" type="module" async></script>
<script app-name="SubscriptionMain" src="./_content/Microsoft.FluentUI.AspNetCore.Components/js/initializersLoader.webview.js"></script>
<script src="_framework/blazor.webview.js"></script>
<link href="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" rel="stylesheet" />
</body>
</html>
Expected Behavior
application start sucessfully.
Steps To Reproduce
No response
Exceptions (if any)
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。
************** 异常文本 **************
System.IO.FileNotFoundException: 系统找不到指定的文件。 (0x80070002)
************** 已加载的程序集 **************
System.Private.CoreLib
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Private.CoreLib.dll
----------------------------------------
SubscriptionMain
程序集版本: 1.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\SubscriptionMain.dll
----------------------------------------
System.Runtime
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Runtime.dll
----------------------------------------
System.Windows.Forms
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\System.Windows.Forms.dll
----------------------------------------
System.ComponentModel.Primitives
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.ComponentModel.Primitives.dll
----------------------------------------
System.Windows.Forms.Primitives
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\System.Windows.Forms.Primitives.dll
----------------------------------------
System.Drawing.Primitives
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Drawing.Primitives.dll
----------------------------------------
System.Collections.Specialized
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Collections.Specialized.dll
----------------------------------------
Microsoft.Win32.Primitives
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\Microsoft.Win32.Primitives.dll
----------------------------------------
System.Runtime.InteropServices
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Runtime.InteropServices.dll
----------------------------------------
System.Collections
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Collections.dll
----------------------------------------
System.Threading
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Threading.dll
----------------------------------------
System.Threading.Thread
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Threading.Thread.dll
----------------------------------------
System.Diagnostics.TraceSource
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Diagnostics.TraceSource.dll
----------------------------------------
System.Drawing.Common
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\System.Drawing.Common.dll
----------------------------------------
Microsoft.Extensions.DependencyInjection.Abstractions
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.DependencyInjection.Abstractions.dll
----------------------------------------
Microsoft.FluentUI.AspNetCore.Components
程序集版本: 4.7.2.24124
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.FluentUI.AspNetCore.Components.dll
----------------------------------------
Microsoft.AspNetCore.Components.WebView.WindowsForms
程序集版本: 1.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.AspNetCore.Components.WebView.WindowsForms.dll
----------------------------------------
Microsoft.Extensions.Http
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.Http.dll
----------------------------------------
Microsoft.Extensions.DependencyInjection
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.DependencyInjection.dll
----------------------------------------
System.ComponentModel
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.ComponentModel.dll
----------------------------------------
System.ObjectModel
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.ObjectModel.dll
----------------------------------------
Microsoft.AspNetCore.Components.Web
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.AspNetCore.Components.Web.dll
----------------------------------------
Microsoft.AspNetCore.Components
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.AspNetCore.Components.dll
----------------------------------------
System.ComponentModel.EventBasedAsync
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.ComponentModel.EventBasedAsync.dll
----------------------------------------
Accessibility
程序集版本: 4.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\Accessibility.dll
----------------------------------------
Microsoft.Web.WebView2.WinForms
程序集版本: 1.0.2151.40
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Web.WebView2.WinForms.dll
----------------------------------------
Microsoft.Web.WebView2.Core
程序集版本: 1.0.2151.40
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Web.WebView2.Core.dll
----------------------------------------
mscorlib
程序集版本: 4.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\mscorlib.dll
----------------------------------------
System.ComponentModel.TypeConverter
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.ComponentModel.TypeConverter.dll
----------------------------------------
System.Numerics.Vectors
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Numerics.Vectors.dll
----------------------------------------
System.Drawing
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\System.Drawing.dll
----------------------------------------
System.Memory
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Memory.dll
----------------------------------------
Microsoft.Win32.SystemEvents
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\Microsoft.Win32.SystemEvents.dll
----------------------------------------
Microsoft.AspNetCore.Components.WebView
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.AspNetCore.Components.WebView.dll
----------------------------------------
Microsoft.Extensions.Logging
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.Logging.dll
----------------------------------------
Microsoft.JSInterop
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.JSInterop.dll
----------------------------------------
Microsoft.Extensions.Logging.Abstractions
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.Logging.Abstractions.dll
----------------------------------------
Microsoft.Extensions.Options
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.Options.dll
----------------------------------------
Microsoft.Extensions.Diagnostics
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.Diagnostics.dll
----------------------------------------
System.Net.Http
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Net.Http.dll
----------------------------------------
System.Diagnostics.DiagnosticSource
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Diagnostics.DiagnosticSource.dll
----------------------------------------
Microsoft.Extensions.FileProviders.Abstractions
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.FileProviders.Abstractions.dll
----------------------------------------
System.Private.Uri
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Private.Uri.dll
----------------------------------------
System.Collections.Concurrent
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Collections.Concurrent.dll
----------------------------------------
System.Diagnostics.Tracing
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Diagnostics.Tracing.dll
----------------------------------------
Microsoft.Extensions.FileProviders.Physical
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.FileProviders.Physical.dll
----------------------------------------
Microsoft.Extensions.Primitives
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.Primitives.dll
----------------------------------------
Microsoft.Extensions.FileProviders.Composite
程序集版本: 8.0.0.0
位置: C:\Users\Administrator\Desktop\Boots\publish\Microsoft.Extensions.FileProviders.Composite.dll
----------------------------------------
System.Threading.ThreadPool
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Threading.ThreadPool.dll
----------------------------------------
System
程序集版本: 4.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.dll
----------------------------------------
System.Runtime.Loader
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Runtime.Loader.dll
----------------------------------------
System.Collections.NonGeneric
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.5\System.Collections.NonGeneric.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 8.0.0.0
位置: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.5\zh-Hans\System.Windows.Forms.resources.dll
----------------------------------------
************** JIT 调试 **************
.NET Version
8.0.300
Anything else?
.NET SDK:
Version: 8.0.300
Commit: 326f6e68b2
Workload version: 8.0.300-manifests.c1c70047
MSBuild version: 17.10.4+10fbfbf2e
运行时环境:
OS Name: Windows
OS Version: 10.0.20348
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.300\
已安装 .NET 工作负载:
没有要显示的已安装工作负载。
Host:
Version: 8.0.5
Architecture: x64
Commit: 087e15321b
.NET SDKs installed:
8.0.300 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Trace Logs
Category: Microsoft.AspNetCore.Components.WebView.WindowsForms.BlazorWebView
EventId: 10
Creating file provider at content root 'C:\Users\Administrator\Desktop\Boots\publish\wwwroot', using host page relative path 'index.html'.
Category: Microsoft.AspNetCore.Components.WebView.WindowsForms.BlazorWebView
EventId: 11
Adding root component 'SubscriptionMain.App' with selector '#app'. Number of parameters: 0
Category: Microsoft.AspNetCore.Components.WebView.WindowsForms.BlazorWebView
EventId: 12
Starting initial navigation to '/'.
Ok, I got it. The reason is WebView2 Runtime not installed on user machine. I guess blazor should check WebView2 Runtime before start?