aspnetcore: Including a NativeFileReference causes a Blazor error in Release mode

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Create a default Blazor WebAssembly App project. Configure for HTTPS only.

This project runs successfully in both Debug and Release mode.

Now add a Folder Data and place in there the e_sqlite3.o file from Steve Sandersons demo.

Add to the Project file the line in Item Group

<NativeFileReference Include="Data\e_sqlite3.o" />

Now the project will run in Debug mode, but in Release mode it gets an error as follows:

blazor.webassembly.js:1 Assertion failed: Cannot call unknown function mono_wasm_set_is_debugger_attached, make sure it is exported

This means that we cannot use Hot Release (currently only runs in Release mode) with a native file.

Expected Behavior

Native Files should be useable in both Debug and Release mode.

Steps To Reproduce

Described above

Exceptions (if any)

blazor.webassembly.js:1 Assertion failed: Cannot call unknown function mono_wasm_set_is_debugger_attached, make sure it is exported

.NET Version

Net 6.0

Anything else?

.NET SDK (reflecting any global.json): Version: 6.0.101 Commit: ef49f6213a

Runtime Environment: OS Name: Windows OS Version: 10.0.19043 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.101\

Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc

.NET SDKs installed: 3.1.406 [C:\Program Files\dotnet\sdk] 5.0.103 [C:\Program Files\dotnet\sdk] 5.0.202 [C:\Program Files\dotnet\sdk] 5.0.300 [C:\Program Files\dotnet\sdk] 5.0.301 [C:\Program Files\dotnet\sdk] 6.0.100 [C:\Program Files\dotnet\sdk] 6.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Microsoft Visual Studio Community 2022 (64-bit) Version 17.0.5

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 35 (17 by maintainers)

Most upvoted comments

@Zhiyuan-Amos It looks like this is due to a change in the runtime. Would you mind filing an issue at https://github.com/dotnet/runtime, indicating clearly that this is related to WebAssembly?

@lewing Not sure if it’s intentional to remove the FS JS API. It would be good to discuss next week and make sure that, if we’re having a breaking change here, we have some way to communicate it and perhaps allow passing some Emscripten flags to restore the FS APIs if relevant.

(Pretty sure iOS will always need that special provider anyway, because it does the DllImport("__Internal") trick.)

@fingers10 yes I encountered that too, but that’s a different issue. 😛 This is the parent issue https://github.com/dotnet/efcore/issues/26288, and a temporary fix can be found here https://github.com/dotnet/efcore/issues/26860.

I managed to resolve it by adding this to my codebase, based on the issue above.

@fingers10 The main differences I can see between your app and the BlazeOrbital sample are:

  • you’re using a different version of Microsoft.EntityFrameworkCore.Sqlite (BlazeOrbital uses 6.0.0-rc.1.21452.10; your app uses 6.0.2),
  • BlazeOrbital defines its own NativeMethods signatures whereas your app does not.

One or both of these is probably responsible for the difference.

However the good news is you don’t need to bundle your own e_sqlite3.o file any more and mess with these low-level details, since support is now built into SQLite’s NuGet package: https://twitter.com/bricelambs/status/1491134363945570305. Could you try using those packages? Thanks!