Closed DaveNatalieTripArc closed 1 year ago
Steps to reproduce
Clone the repo, and change the TargetFramework in the
MauiCSharpInteropWebView
to<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
When running the application, you'll get a null reference exception with no additional info (all threads are executing external code).
I am currently using Maui
8.0.0-preview.7.8842
Edit: It works on Windows, but does not work on Android. I have not tried iOS.
Same issue on Android Working on iOS!!!
Thanks for the report, I'll try this out. Hopefully an easy fix!
Hi @DaveNatalieTripArc , @nelsonrc - I tried using .NET 8 Preview 7 and was able to run it fine after changing the TargetFrameworks
entries. Are you able to run the app with the debugger and see what the exception is?
To enable ALL exceptions, go to Debug/Windows/Exception Settings:
And make sure there's a CHECKED checkbox (not just a square) for Common Language Runtime Exceptions:
Alright thanks to a stack trace from @bethmassi I think I know the bug. I'm testing a fix.
I believe the bug is in this line: https://github.com/Eilon/MauiHybridWebView/blob/d21a70d7e46310d84e3e2a0a414cb012b790baa2/HybridWebView/HybridWebViewHandler.cs#L35
And change the !
to a ?
so that the field can be null (which is fine on .NET 8, but is needed on .NET 7).
The MAUI change that necessitated this change here is this PR: https://github.com/dotnet/maui/pull/16032
Now that the fix is checked in here, I'll see when I can push a NuGet package update. Thanks for the report!
Thanks for fixing that so quickly. I look forward to trying out the peview-4 release once it becomes available.
@DaveNatalieTripArc the fix should be available in the updated package: https://www.nuget.org/packages/EJL.MauiHybridWebView/1.0.0-preview4
I update the package and working now!!!!
Thanks
With a quick check, it looks like the null reference exception is gone!
However, on Android, my page doesn't actually load, and I get a Connection Refused message.
This same code is working on Windows, but there is probably something wrong I am doing on my end. I'll look into it more when I get a chance.
Okay, this is working properly, the problem is on my end.
I was trying to share my Raw Html in a separate assembly, so that two different apps can use the same web content.
I added this to my shared library.
<ItemGroup>
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
It seems to work on Windows, but Android doesn't like it. In any case, this has nothing to do with the null reference exception we were getting.
Thanks again for the fix.
@DaveNatalieTripArc can you log a new bug with a full repro app so I can investigate?
Steps to reproduce
Clone the repo, and change the TargetFramework in the
MauiCSharpInteropWebView
toWhen running the application, you'll get a null reference exception with no additional info (all threads are executing external code).
I am currently using Maui
8.0.0-preview.7.8842
Edit: It works on Windows, but does not work on Android. I have not tried iOS.