Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

SerialPorts with .NET Standard 2.1

Discussion in 'Experimental Scripting Previews' started by Wobling-Quell, May 23, 2022.

  1. Wobling-Quell

    Wobling-Quell

    Joined:
    Mar 2, 2022
    Posts:
    3
    Hi,
    Sorry if this is in the wrong place.

    I'm trying to get serial ports working with .NET Standard 2.1. It works with .NET Framework but ideally, I don't want to use this if I don't have to.

    I understand that .NET 2.0 was the last version to have serial support directly and now it's available via the NuGet package https://www.nuget.org/packages/System.IO.Ports/
    However, I'm unable to get this to work.

    Using the .NET Standard 2.0 gets me the following error:

    Code (CSharp):
    1. Exception: System.IO.Ports is currently only supported on Windows. StackTrace:   at System.IO.Ports.SerialPort..ctor (System.String portName, System.Int32 baudRate) [0x0000b] in <c6d1344d4a914d5aba16ee2e4d4a5e71>:0
    2.   at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort..ctor(string,int)
    3.  
    I'm wondering if it's possible to use the mono implementation? I tried to include it using a csc.rsp but no luck.

    Any help is greatly appreciated.

    EDIT: I actually managed to get this to work in the end.
    When opening the NuGet package I was using the netstandard2.0 dll's from the lib directory but I noticed there is a runtime directory with the same netstandard2.0 directory and dll's. I used this with my editor set to .NET Standard 2.1 and it works.

    I hope this helps those in the future.
     
    Last edited: May 23, 2022
    domFC, ziyingwong, domportera and 4 others like this.
  2. nonokolli

    nonokolli

    Joined:
    Jun 29, 2022
    Posts:
    1
    Hi, I received the same error message - only supported on windows even though I have NET standard 2.1. And seems my OVR camera rigs are missing too. Do you know any alternative in solving this issue?
     
  3. mattdsmith228

    mattdsmith228

    Joined:
    Nov 17, 2022
    Posts:
    1
    Still looking for a solution for this.