SamProf / MatBlazor

Material Design components for Blazor and Razor Components
http://www.matblazor.com
MIT License
2.84k stars 384 forks source link

Running server/client from console fails #457

Open hailstorm75 opened 4 years ago

hailstorm75 commented 4 years ago

Description

If I run the MatBlazor.Demo.ServerApp.exe from a console on Windows the application will fail with the following exception:

Microsoft.JSInterop.JSException: Could not find 'matBlazor' in 'window'. Error: Could not find 'matBlazor' in 'window'. at https://localhost:5001/_framework/blazor.server.js:8:30748 at Array.forEach () at p (https://localhost:5001/_framework/blazor.server.js:8:30709) at https://localhost:5001/_framework/blazor.server.js:8:31416 at new Promise () at e.beginInvokeJSFromDotNet (https://localhost:5001/_framework/blazor.server.js:8:31390) at https://localhost:5001/_framework/blazor.server.js:1:19202 at Array.forEach () at e.invokeClientMethod (https://localhost:5001/_framework/blazor.server.js:1:19173) at e.processIncomingData (https://localhost:5001/_framework/blazor.server.js:1:17165) at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args) at MatBlazor.BaseMatComponent.JsInvokeAsync[T](String code, Object[] args) in c:\Users\Denis\Source\Repos\MatBlazor\src\MatBlazor\Components\Base\BaseMatComponent.cs:line 83 warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100] Unhandled exception rendering component: Could not find 'matBlazor' in 'window'. Error: Could not find 'matBlazor' in 'window'. at https://localhost:5001/_framework/blazor.server.js:8:30748 at Array.forEach () at p (https://localhost:5001/_framework/blazor.server.js:8:30709) at https://localhost:5001/_framework/blazor.server.js:8:31416 at new Promise () at e.beginInvokeJSFromDotNet (https://localhost:5001/_framework/blazor.server.js:8:31390) at https://localhost:5001/_framework/blazor.server.js:1:19202 at Array.forEach () at e.invokeClientMethod (https://localhost:5001/_framework/blazor.server.js:1:19173) at e.processIncomingData (https://localhost:5001/_framework/blazor.server.js:1:17165) Microsoft.JSInterop.JSException: Could not find 'matBlazor' in 'window'. Error: Could not find 'matBlazor' in 'window'. at https://localhost:5001/_framework/blazor.server.js:8:30748 at Array.forEach () at p (https://localhost:5001/_framework/blazor.server.js:8:30709) at https://localhost:5001/_framework/blazor.server.js:8:31416 at new Promise () at e.beginInvokeJSFromDotNet (https://localhost:5001/_framework/blazor.server.js:8:31390) at https://localhost:5001/_framework/blazor.server.js:1:19202 at Array.forEach () at e.invokeClientMethod (https://localhost:5001/_framework/blazor.server.js:1:19173) at e.processIncomingData (https://localhost:5001/_framework/blazor.server.js:1:17165) at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args) at MatBlazor.BaseMatComponent.JsInvokeAsync[T](String code, Object[] args) in c:\Users\Denis\Source\Repos\MatBlazor\src\MatBlazor\Components\Base\BaseMatComponent.cs:line 83 at MatBlazor.BaseMatAppBar.OnFirstAfterRenderAsync() in c:\Users\Denis\Source\Repos\MatBlazor\src\MatBlazor\Components\MatAppBar\BaseMatAppBar.cs:line 29 at MatBlazor.BaseMatComponent.OnAfterRenderAsync(Boolean firstRender) in c:\Users\Denis\Source\Repos\MatBlazor\src\MatBlazor\Components\Base\BaseMatComponent.cs:line 28 at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Running from Visual Studio works fine. Running the Demo ServerApp using dotnet run on the csproj also works (suppose that is what Visual Studio uses). However, running the exe or dll directly using dotnet or just by starting the exe results in this error.

Before this commit 2a0e2a9ad635dd6d0db52ea730b3e46a55d5bc4e everything worked fine.

STR:

  1. Build the ServerApp
  2. Open cmd
  3. Navigate to the /bin folder of said project
  4. Input either of the following commands:
    • MatBlazor.Demo.ServerApp.exe
    • dotnet MatBlazor.Demo.ServerApp.exe
  5. Open the localhost page of the application
  6. Observe the missing page style and the error logged in the console

Additional info

I have first encountered this error after upgrading from 1.x to 2.x and was convinced that I have configured the MatBlazor theme incorrectly (see #428)

As of now I was unable to figure out the source of the issue by inspecting 2a0e2a9ad635dd6d0db52ea730b3e46a55d5bc4e. I suppose the main focus of this commit was to fix issues regarding the Client application (couldn't find the issue number related to this commit).

Simply reverting it fixes the said problem and everything loads up nicely.

Christian-Oleson commented 3 years ago

@hailstorm75 , Is this still an issue?

hailstorm75 commented 3 years ago

I'll come back to you on that in a few days, don't close the issue yet please

hailstorm75 commented 3 years ago

image

The issue persists, I've manually updated the MatBlazor package to the latest in my project: https://dev.azure.com/DenisAkopyan/_git/Borec

Running on a machine with VS Code only, no full Visual studio (never even been installed on it). The stacktrace is the same.