Share via


Can't find system.IO.Ports namespace

Question

Monday, March 12, 2018 2:02 PM

Hi! 
I'm trying to add system.IO.ports namespace to my project. It cannot be found.
Same problem as here:
 https://social.msdn.microsoft.com/Forums/en-US/b26a1796-5340-4e12-81f7-035cb537fc9b/cannot-find-systemioports-in-visual-studio-2017?forum=visualstudiogeneral

I have tried creating project which uses .NET Framework. Still cannot be found, it's not even in object browser.
Help is really apprectiated, thanks

All replies (5)

Tuesday, March 13, 2018 5:49 AM

Hi Niko19861,

Welcome to the MSDN forum.

>> I have tried creating project which uses .NET Framework. Still cannot be found, it's not even in object browser.

What’s the version of Visual Studio do you use?

What’s the .NET Framework project do you use?

Please check the System assembly has been added under the project References list. If not, please add it. You could right click the References of your project in Solution Explorer, choose Add Reference…, click Browse… under Browse tab in Reference Manager dialog box, find the “System.dll” to add, it located in path “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\NETFramework\v4.6.1\System.dll”. Then, add namespace “using System.IO.Ports;”, check the result.

If you want to use serial port communication in Universal Window project, please have a look at this thread might helpful for you: https://stackoverflow.com/questions/31124703/using-system-io-ports-c-sharp-windows-iot-univeral

In addition, could you please share me your project? You could upload your project to OneDrive and share a link here, that will be helpful to test your issue in my side and find the solution.

Thanks for your understanding.

Regards,

Judyzh

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, March 13, 2018 12:28 PM

Hi and thank you from your answer.

I am using Visual Studio Professional 2017 Version 15.6.1  and framework version is 4.7.02556.

"Please check the System assembly has been added under the project References list. If not, please add it. You could right click the References of your project in Solution Explorer, choose Add Reference…, click Browse… under Browse tab in Reference Manager dialog box, find the “System.dll” to add, it located in path “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\NETFramework\v4.6.1\System.dll”. Then, add namespace “using System.IO.Ports;”, check the result." 

I tried what you suggested, still doesn't work, it says  "A reference to “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\NETFramework\v4.5\System.dll”  could not be added . This component is already automatically referenced by the build system" (didn't find v.4.6.1 folder there)

The project itself is at it's start because i cant get this work. It still says "The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)" when i try to add System.IO.Ports.


Wednesday, March 14, 2018 9:37 AM

Hi Niko19861,

What kind of project are you using?

>> I'm trying to add system.IO.ports namespace to my project. It cannot be found.

I notice that you use “system.IO.ports”, please use “System.IO.ports”, if you use system with lower case, it will not be found.

In addition, please share the screenshot of the error to me, that will be helpful to find the solution. You could upload the screenshot to OneDrive, then, share a link here.

Regards,

Judyzh

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Wednesday, March 14, 2018 8:55 PM

I am using Visual C#, Universal Windows Blank app.
Here are the screenshots:

https://1drv.ms/u/s!Aoc15OwZlnVFbcrOG4kEbr_j6Lk
https://1drv.ms/u/s!Aoc15OwZlnVFbpnBCr7pOn5ujKk
https://1drv.ms/u/s!Aoc15OwZlnVFb\_-ytjqE3VPaQAA

I have figured out if i go to File -> New -> File -> Visual C# Class, i can find “System.IO.ports” but when i add file to the project using Project -> Add New Item -> Visual C# Class, i can't use System.IO.Ports anymore.


Thursday, March 15, 2018 6:13 AM

Hi Niko19861,

As far as I know, this apis does not support UWP project.

/en-us/dotnet/api/?view=netstandard-2.0&term=System.IO.ports

If your UWP project involves file flow operations, please use Windows.Storage Namespace.

If your UWP project involves a serial port, please use Windows.Devices.SerialCommunication Namespace.

Regards,

Judyzh

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].