The type or namespace name 'Ports' does not exist in the namespace 'System.IO'

14,503

Solution 1

Go to Edit->projectsettings->Player->APIcompetibilityLevel = .Net4.x This worked for me.

Solution 2

Problem is the .net configuration.

Use the .NET 2.0 (not subset). Config:

Edit>ProjectSettings>Player>ApiCompatibilityLevel

Share:
14,503

Related videos on Youtube

shikha shrivastva
Author by

shikha shrivastva

Updated on June 04, 2022

Comments

  • shikha shrivastva
    shikha shrivastva almost 2 years

    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

    • Vajura
      Vajura over 9 years
      you probably need to add a reference right click on your project in solution explorer and add reference
    • Alan
      Alan over 9 years
      Windows Store apps are extremely restricted - it's entirely possible that the Windows Runtime doesn't provide the functionality you need.
    • Heslacher
      Heslacher over 9 years
      See the comment here http://stackoverflow.com/q/25710474/2655508. Hans Passant knows about what he is talking.
    • shikha shrivastva
      shikha shrivastva over 9 years
      I have already tried adding the reference. I have tried adding system.dll but getting this error -"A reference to System.dll could not be added. This component is already automatically referenced by the build system"
    • shikha shrivastva
      shikha shrivastva over 9 years
      Do we have any other way to communicate through the RS-232 port other than serialport ?
    • shikha shrivastva
      shikha shrivastva over 9 years
      And I am facing this issue on Windows 8.1 Enterprise and not windows RT
    • Heslacher
      Heslacher over 9 years