dotnet / dotnet-wasi-sdk

An SDK for building .NET projects as standalone WASI-compliant modules
MIT License
276 stars 12 forks source link

Get issue while running with Wasmedge #5

Open trumhemcut opened 1 year ago

trumhemcut commented 1 year ago

I've tried to create a web app and build with wasi. It run well with wasmtime but not with wasmedge. Could you please help take a look?

This is package version using in the app:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <WasiRunnerArgs>--tcplisten localhost:5000 --env ASPNETCORE_URLS=http://localhost:5000</WasiRunnerArgs>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Wasi.AspNetCore.Server.Native" Version="0.1.2-preview.10061" />
    <PackageReference Include="Wasi.Sdk" Version="0.1.2-preview.10061" />
    <WasmBundleFiles Include="wwwroot\**" />
  </ItemGroup>

</Project>

Run well with wasmtime:

wasmtime ./bin/Debug/net7.0/MyWebApp.wasm --tcplisten localhost:5000
info: Microsoft.Hosting.Lifetime
      Now listening on: http://localhost:5000

Issue while running with wasmedge:

wasmedge ./bin/Debug/net7.0/MyWebApp.wasm                           
[2022-11-12 21:32:21.639] [error] instantiation failed: incompatible import type, Code: 0x61
[2022-11-12 21:32:21.640] [error]     Mismatched function type. Expected: FuncType {params{i32 , i32 , i32} returns{i32}} , Got: FuncType {params{i32 , i32} returns{i32}}
[2022-11-12 21:32:21.640] [error]     When linking module: "wasi_snapshot_preview1" , function name: "sock_accept"
[2022-11-12 21:32:21.640] [error]     At AST node: import description
[2022-11-12 21:32:21.640] [error]     At AST node: import section
[2022-11-12 21:32:21.640] [error]     At AST node: module
zhangchaoza commented 1 year ago

I found an answer witch maybe useful https://github.com/WasmEdge/WasmEdge/issues/2056#issuecomment-1308348306

alabulei1 commented 1 year ago

Hi @trumhemcut ,

WasmEdge 0.12.1 is released recently with support for the WASI socket proposal. Now the .net program should be able to run in WasmEdge. Please try again when you're free. Feel free to let me know if it works. Thanks.