![](/img/trans.png)
[英]Can I get the device handle for a serial port that I am accessing using the .net SerialPort class?
[英]Accessing the SerialPort class using .Net Core 3.0
我正在開始一個新的 .NET Core 3.0 項目,我需要在其中訪問 System.IO.Ports.SerialPort class。 The documentation I'm reading on the class shows that it is applicable to .NET Core 3 ( see the bottom of https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view =netcore-3.0 )。 但是,當我向 class 添加 using 語句時,它無法解析 System.IO.Ports。 是否需要執行一些額外的步驟來引用在 Windows 桌面上運行的 .NET Core 3.0 程序的 SerialPort class?
我正在使用.NET Core 3.1構建Blazor應用程序。 Visual Studio 2019沒有給我上下文菜單項“安裝 package 'System.IO.Ports'”。 我通過轉到 DOS 提示符來解決這個問題。
cd <project_path>
dotnet add package Microsoft.Extensions.Configuration --version 5.0.0
dotnet add package System.IO.Ports --version 5.0.0
這似乎可以解決問題。
我有同樣的問題,這對我有用。 只是我下載並安裝了 package,一切正常。 謝謝。
您需要執行以下操作:工具 > 命令行 > 開發人員命令提示並執行以下命令: dotnet add package System.IO.Ports
您也可以通過 NuGet 包添加它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.