Skip to content

Friendlier exception when invoking JS from outside a WebView context #40943

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

Merged
merged 1 commit into from
Mar 30, 2022

Conversation

MackinnonBuck
Copy link
Member

Friendlier exception when invoking JS from outside a WebView context

Attempting to invoke JS from outside a WebView context (e.g. calling IJSRuntime methods in a WPF or WinForms application outside a Razor component) previously resulted in a NullReferenceException getting thrown. This PR throws a different exception that helps the developer understand that what they're attempting to do is not allowed.

Fixes dotnet/maui#1245

@MackinnonBuck MackinnonBuck requested a review from a team as a code owner March 29, 2022 22:45
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Mar 29, 2022
@SteveSandersonMS
Copy link
Member

Great!

@MackinnonBuck MackinnonBuck merged commit 4c7c1b7 into main Mar 30, 2022
@MackinnonBuck MackinnonBuck deleted the mbuck/friendlier-js-invocation-exception branch March 30, 2022 15:45
@ghost ghost added this to the 7.0-preview3 milestone Mar 30, 2022
@dougbu dougbu modified the milestones: 7.0-preview3, 7.0-preview4 Apr 5, 2022
@TanayParikh
Copy link
Contributor

Do we want to backport this to 6.0 @dotnet/dotnet-maui-blazor-eng?

@Eilon
Copy link
Contributor

Eilon commented Apr 13, 2022

@TanayParikh I would say no. It hasn't come up all that much. If we see otherwise we could consider it.

@dotnet dotnet deleted a comment Apr 13, 2022
@MackinnonBuck MackinnonBuck restored the mbuck/friendlier-js-invocation-exception branch April 15, 2022 16:15
@MackinnonBuck MackinnonBuck deleted the mbuck/friendlier-js-invocation-exception branch April 15, 2022 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BlazorWinFormsApp and BlazorWpfApp throw NullReferenceException when using ExampleJsInterop in .NET 6 Preview 3
6 participants