SteveSandersonMS / dotnet-wasi-sdk

Packages for building .NET projects as standalone WASI-compliant modules
519 stars 36 forks source link

System.Data.SqlClient fails to resolve #27

Closed tfbrandt closed 2 years ago

tfbrandt commented 2 years ago

Built simple app to test SqlClient (expected it not to connect). Followed normal build and wasmtime run commands. build was successful with no errors but when running I get:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.6.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. File name: 'System.Data.SqlClient, Version=4.6.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Its as if the Wasm.Sdk build did not locate the .dll and include it into my .dll

SteveSandersonMS commented 2 years ago

The SqlClient NuGet package includes platform-specific native code as well as the .NET assembly. Native code can't run inside WebAssembly, and can't even be loaded into the runtime. That's probably why it says it's unable to load the .NET assembly that relies on it.

To make this work, we'd need a build of the SqlClient package in which the native code is compiled to WebAssembly instead of a Windows DLL / mac dylib / Linux .so file.

Closing as that's outside the scope of anything that could be resolved in this repo. Longer term, if .NET becomes officially supported in WASI environments, we'd want to work with the team producing the SqlClient package to find the best way to handle this. Hope that makes sense!