I am working on developing a windows store app on my windows 8.1 system,64 bit (I need to deploy this app on my windows surface pro 3 tablet), technology being used is C#. I need to communicate through the RS-232 port. For this I am using the SerialPort class which falls under the namespace System.IO.Ports. But when I am including this in my C# code, I am getting the error -
"The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)"
I have the windows SDK 8.0 installed. What could be the probable reason for this issue ? Is there any other was to communicate through the RS-232 port .
I am working on developing a windows store app on my windows 8.1 system,64 bit (I need to deploy this app on my windows surface pro 3 tablet), technology being used is C#. I need to communicate through the RS-232 port. For this I am using the SerialPort class which falls under the namespace System.IO.Ports. But when I am including this in my C# code, I am getting the error -
"The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)"
I have the windows SDK 8.0 installed. What could be the probable reason for this issue ? Is there any other was to communicate through the RS-232 port .
Any pointer or suggested would be really helpful.
Here is the code -
using System;
using System.IO;
using System.IO.Ports;
namespace App4
{
public class Class2
{
private SerialPort comport = new SerialPort();
}
private void SerialPortInit()
{
comport.BaudRate = 115200;
comport.DataBits = 8;
comport.StopBits = StopBits.One;
comport.Parity = Parity.None;
}
}
Google says that Serialport class is supported in dotNetFrameWork 4.5 (which is the one I am using) but still I am getting this error.
Regards, Shikha
Problem is the .net configuration.
Use the .NET 2.0 (not subset). Config:
Edit>ProjectSettings>Player>ApiCompatibilityLevel
转到 Edit->projectsettings->Player->APIcompetibilityLevel = .Net4.x 这对我有用。
*This answer is valid for VC++ but I think it is same or similar for C#.
Open Project Properties -> C/C++ -> Command Line. There is an "Additional Options" box below. Add following lines to there:
/FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Drawing.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Windows.Forms.dll" /FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Xml.dll"
Pay attention to the path and .NET version before adding them.
I hit the same issue with .Net Core 3.1
How to build cross-platform console apps with .NET Core
Add following to .csproj:
<PropertyGroup>
<RuntimeIdentifiers>win10-x64;osx.10.12-x64;debian.8-x64</RuntimeIdentifiers>
Then installed the package System.IO.Ports 4.7.0
Open the project as .Net Framework instead of .Net Core, this fixed my issue. I was missing IO.Ports and My.Computer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.