title: System.IO.FIleNotFoundException with System.IO.Ports
body: <p>I want to use the SerialPort framework of .NET and just learning the ropes of coding in a Windows Environment in C#. I am not new to coding, but I have still challenges understanding the Windows environment.</p>
  
  <p>I get the following error when trying to start the program:</p>
  
  <pre><code>System.IO.FileNotFoundException
    HResult=0x80070002
    Message=Could not load file or assembly 'System.IO.Ports, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
    Source=ConnectionRepository.Serial
    StackTrace:
     at ConnectionRepository.Serial.SerialConnection.GetSerialPortNames() in C:\Users\KG-OFFICE\source\repos\DeepSky\ConnectionRepository.Serial\SerialConnection.cs:line 17
     at DeepSky.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\KG-OFFICE\source\repos\DeepSky\DeepSky\Form1.cs:line 25
     at System.Windows.Forms.Form.OnLoad(EventArgs e)
     at System.Windows.Forms.Form.OnCreateControl()
     at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
     at System.Windows.Forms.Control.CreateControl()
     at System.Windows.Forms.Control.WmShowWindow(Message&amp; m)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ScrollableControl.WndProc(Message&amp; m)
     at System.Windows.Forms.Form.WmShowWindow(Message&amp; m)
     at System.Windows.Forms.Form.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  </code></pre>
  
  <p>The class using SerialPort I wrote looks like this:</p>
  
  <pre><code>using ConnectionRepository.Interface;
  using System;
  using System.IO.Ports;
  
  namespace ConnectionRepository.Serial
  {
      public class SerialConnection : IConnectionRepository
      {
  
          static SerialPort _serialPort;
  
          public static string[] GetSerialPortNames()
          {
              string[] portNames = SerialPort.GetPortNames();
  
              return portNames;
          }
  
          public void CloseConnection()
          {
              throw new NotImplementedException();
          }
  
          public void OpenConnection()
          {
              _serialPort = new SerialPort();
              _serialPort.Open();
          }
      }
  }
  </code></pre>
  
  <p>The main program:</p>
  
  <pre><code>namespace DeepSky
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              IConnectionRepository serialConnection = new SerialConnection();
              string[] portNames = SerialConnection.GetSerialPortNames();
              cBoxComPort.Items.AddRange(portNames);
          }
      }
  }
  </code></pre>
  
  <p>when I added <code>System.IO.Ports</code> it first did not recognize it and threw an error message. Then I read, I need to add it via NuGet, which I did and the error disappeared. But when building the solution, I get this error above.</p>
  
  <p>I also added the references accordingly, but can't get it to run. Can you help me out?</p>