title: How to fix a Memory Map Failed Exception for GPIO write on raspberry pi
body: <p>I'm trying to use the Raspberry Sharp IO library to write to a pin on the Pi. But it gives me an exception on runtime. It had worked before, but doesnt any more. Why is this error being thrown? </p>
  
  <pre><code>using System;
  using Raspberry.IO.GeneralPurpose;
  using Raspberry.IO.GeneralPurpose.Behaviors;
  using System.Threading;
  
    namespace blinky
      {
         class MainClass
       {
      public static void Main (string[] args)
      {
  
      // Here we create a variable to address a specific pin for output
      // There are two different ways of numbering pins--the physical numbering, and the CPU number
      // "P1Pinxx" refers to the physical numbering, and ranges from P1Pin01-P1Pin40
          var led1 = ConnectorPin.P1Pin03.Output();
  
      // Here we create a connection to the pin we instantiated above
      var connection = new GpioConnection(led1);
  
      while(true){
          // Toggle() switches the high/low (on/off) status of the pin
          connection.Toggle(led1);
          Thread.Sleep(250);
      }
  
  //  connection.Close();
  
  }
  }
   }
  </code></pre>
  
  <p>returns this error:</p>
  
  <pre><code>pi@Minion01 ~/blinky1/blinky1/bin/Debug $ mono ./blinky1.exe
  
  Unhandled Exception:
  Raspberry.IO.Interop.MemoryMapFailedException: Exception of type 'Raspberry.IO.Interop.MemoryMapFailedException' was thrown.
    at Raspberry.IO.Interop.MemoryMap.ThrowOnError[MemoryMapFailedException] (IntPtr result) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.Interop.MemoryMap.Create (IntPtr address, UInt32 size, MemoryProtection protection, MemoryFlags memoryflags, Int32 fileDescriptor, UInt32 offset) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionDriver..ctor () [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.GetBestDriver (GpioConnectionDriverCapabilities capabilities) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in &lt;filename unknown&gt;:0 
    at blinky.MainClass.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0 
  [ERROR] FATAL UNHANDLED EXCEPTION: Raspberry.IO.Interop.MemoryMapFailedException: Exception of type 'Raspberry.IO.Interop.MemoryMapFailedException' was thrown.
    at Raspberry.IO.Interop.MemoryMap.ThrowOnError[MemoryMapFailedException] (IntPtr result) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.Interop.MemoryMap.Create (IntPtr address, UInt32 size, MemoryProtection protection, MemoryFlags memoryflags, Int32 fileDescriptor, UInt32 offset) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionDriver..ctor () [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.GetBestDriver (GpioConnectionDriverCapabilities capabilities) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in &lt;filename unknown&gt;:0 
    at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in &lt;filename unknown&gt;:0 
    at blinky.MainClass.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0 
  </code></pre>
  
  <p>How may i fix it?</p>