Packaged WPF Blazor WebView app crashes when looking for wwwroot in system32
See original GitHub issueDescription
When using a WPF app with a BlazorWebView hosting a component from a Razor class library, the app will run as expected. However, including the WPF app in an MSIX packaging project and running it will instead result in a DirectoryNotFoundException when it attempts to locate wwwroot in system32.
I have created a repro that shows the issue in this repo
Steps to Reproduce
- Create a Razor class library with Blazor components
- Create a WPF app, update the Project SDK and add the required packages/references
- Add a
BlazorWebViewcontrol, using a component from the RCL - Run the WPF app directly (this works!)
- Add the WPF app to an MSIX packaging project
- Debug the packaging project to run the packaged app: exception occurs.
Version with bug
Preview 11
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 10
Did you find any workaround?
None found, but I originally thought this would be fixed by #3582 .
Relevant log output
System.IO.DirectoryNotFoundException
HResult=0x80070003
Message=C:\WINDOWS\system32\wwwroot\
Source=Microsoft.Extensions.FileProviders.Physical
StackTrace:
at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
at Microsoft.AspNetCore.Components.WebView.Wpf.BlazorWebView.StartWebViewCoreIfPossible()
at Microsoft.AspNetCore.Components.WebView.Wpf.BlazorWebView.OnApplyTemplate()
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Window.MeasureOverrideHelper(Size constraint)
at System.Windows.Window.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Window.SetRootVisual()
at System.Windows.Window.SetRootVisualAndUpdateSTC()
at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
at System.Windows.Window.CreateSourceWindowDuringShow()
at System.Windows.Window.SafeCreateWindowDuringShow()
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at WpfHost.App.Main()
This exception was originally thrown at this call stack:
[External Code]
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (6 by maintainers)
Top Results From Across the Web
Packaged WPF Blazor WebView app crashes when ...
Packaged WPF Blazor WebView app crashes when looking for wwwroot in system32 · Packaged WPF Blazor WebView app crashes when looking for wwwroot...
Read more >using wwwroot from other project in BlazorWebView
I'm trying to build an application using a Blazor Hybrid Webview, which can be run both from a .NET MAUI application as well...
Read more >Blazor app crashes when debugging after windows ...
Blazor app crashes when debugging after windows secutiry updates - Microsoft Q&A.
Read more >Blazor Hybrid WPF styling not working
I'm trying to get a new app working using Blazor Hybrid with WPF. I created the WPF app and got everything running but...
Read more >WPF Apps crash on Windows 10/11 after ...
My company develops . NET WPF apps (32-bit, targeting . NET Framework 4.7. 2, and 4.5 for one of the old ones) written...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yep, updated everything to the latest and it seems to run, seems like it’s fixed.
WORKS FOR ME!!!