WebAssembly and System.IO.Ports package

2021-01-14T16:21:33.977+00:00

Has anyone had any luck creating a c# Net Standard 2.1 RS232 serial coms library using the System.IO.Ports package for use with a WebAssembly project. It would seem there's an issue with the Nuget package containing the wrong version of System.IO.Ports (based on some posts I've read) so what I did was to add a reference to the correct System.IO.Ports.dll library and added in the other packages separately E.g System.Memory & System.Buffers etc. However I'm having an issue when I call SerialPort.Open(). In that the browser throws this exception.

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

  Unhandled exception rendering component: kernel32.dll assembly:<unknown assembly> type:<unknown type> member:(null)

System.DllNotFoundException: kernel32.dll assembly:<unknown assembly> type:<unknown type> member:(null)...

Can anyone shed any light on this? am I using the correct library or is there something better?

Thanks in advance

Darren

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,479 questions
{count} votes

1 answer

Sort by: Most helpful
  1. 2021-01-19T11:12:57.17+00:00

    That's a Blazor server app, from what I now understand it isn't possible to talk to the client PC's com port because the web assembly app effectively runs in a mono sandbox. I've now amended my approach by creating a web api service and calling into that.

    0 comments No comments