Skip to content
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

Hotkeys2 and MAUI Blazor Hybrid compatibility #17

Open
tnglemongrass opened this issue Mar 13, 2024 · 4 comments
Open

Hotkeys2 and MAUI Blazor Hybrid compatibility #17

tnglemongrass opened this issue Mar 13, 2024 · 4 comments

Comments

@tnglemongrass
Copy link

tnglemongrass commented Mar 13, 2024

I try to use the Hotkeys2 library in a MAUI Blazor Hybrid App with .NET 8, following the instructions from the Hotkeys2 README.

Maybe there is just something missing in the README instructions?

Description:

When using the HotKeys2 library in a Maui Blazor Hybrid App, an error/warning is displayed on startup. However, the app runs fine and hotkeys work as expected.

Steps to Reproduce:

Expected Behavior:

There should be no errors or warnings on startup.

Actual Behavior:

The following error message is displayed on startup:

Toolbelt.Blazor.HotKeys2.HotKeys: Error: Could not find 'Toolbelt.Blazor.getProperty' ('Toolbelt' was undefined).
Error: Could not find 'Toolbelt.Blazor.getProperty' ('Toolbelt' was undefined).

Additional Information:

The app runs fine and hotkeys work as expected, despite the error message.

A minimal reproducible example is here: https://github.com/tnglemongrass/ToolbeltHotkeys2Demo/

@jsakamoto
Copy link
Owner

@tnglemongrass Thank you for letting me know about the problem. I must have overlooked the Blazor Hybrid scenario. As a workaround for a while, could you try to add one <script> tag in the wwwroot/index.html for the content, "_content/Toolbelt.Blazor.GetProperty.Script/Toolbelt.Blazor.GetProperty.Script.lib.module.js", like the following pull request?

tnglemongrass/ToolbeltHotkeys2Demo#1

Actually, I've never tried that workaround on my side yet because I've been a bit busy these weeks. I'm sorry for that. Anyway, I hope the workaround above works well. (And I'd like to fix this problem someday.)

@tnglemongrass
Copy link
Author

@jsakamoto Yes, including that script tag fixes it. Thanks for looking into it and thanks a lot for that workaround!

@fingers10
Copy link

@jsakamoto I was also having the same issue when trying to run ilovedotnet blazor wasm project via blazor hybrid project... Adding the script as mentioned solves the exception.

You can use https://github.com/ILoveDotNet/ilovedotnet/tree/main/MAUI to test.

@jsakamoto
Copy link
Owner

jsakamoto commented Jun 27, 2024

[FYI]
This problem is a bug in the .NET SDK.

See also: dotnet/maui#15234

Fortunately, I've verified the problem went away on the .NET 9 SDK Preview 5. So, please take the workaround of explicitly adding a script loading as below until the release of the .NET 9 SDK.

<!-- wwwroot/index.html -->
<!-- 👇 Add this script tag before the script tag, which loads the "blazor.webview.js" JavaScript file. -->
<script src="_content/Toolbelt.Blazor.GetProperty.Script/Toolbelt.Blazor.GetProperty.Script.lib.module.js" type="module"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants