title: C#/Mono - Issue with memory mapped file
body: <p>EDIT: I've update mono (had to compile from source using <a href="http://neildanson.wordpress.com/2013/12/10/building-mono-on-a-raspberry-pi-hard-float/" rel="nofollow">these instructions</a>) to version 3.2.7.  I am no longer getting an error complaining about the capacity overload argument, now I am getting the error below.  Previously, when using mono verison 2.1, I was able to open a small text file as a memory mapped file as a test.  Using the new version of mono I get this same error no matter what file I am trying to open/which overload arguments supply or leave out.  A quick google search didn't yield anything so I'm turning back to you, stackoverflow.  What should I do?</p>
  
  <p><code>Unhandled Exception:
  System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---&gt; System.EntryPointNotFoundException: Mono_Posix_Syscall_get_at_fdcwd
    at (wrapper managed-to-native) Mono.Unix.Native.Syscall:get_at_fdcwd ()
    at Mono.Unix.Native.Syscall..cctor () [0x00000] in &lt;filename unknown&gt;:0
    --- End of inner exception stack trace ---
    at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path) [0x00000] in &lt;filename unknown&gt;:0
    at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0
  [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---&gt; System.EntryPointNotFoundException: Mono_Posix_Syscall_get_at_fdcwd
    at (wrapper managed-to-native) Mono.Unix.Native.Syscall:get_at_fdcwd ()
    at Mono.Unix.Native.Syscall..cctor () [0x00000] in &lt;filename unknown&gt;:0
    --- End of inner exception stack trace ---
    at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path) [0x00000] in &lt;filename unknown&gt;:0
    at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0
  </code></p>
  
  <p>I am working on a project involving controlling GPIO pins on a beaglebone.  I am trying to port some python code into C# (a language I'm not super familiar with) and have run into an issue trying to open the registers on the board located in /dev/mem as memory mapped files like I did in python.  I am writing and compiling the code in visual studio 2010 with .Net framework version 4.0.30319 and running it in ubuntu using mono with compiler version 2.10.8.1.</p>
  
  <p>The stripped down code is as follows: </p>
  
  <pre><code>long offset = 0x4804c000;
  long length = 0xfff;
  using (var mm0 = MemoryMappedFile.CreateFromFile(@"/dev/mem", FileMode.Open, 
                   "gpio1", capacity))
  {
      using (var accessor = mm0.CreateViewAccessor(offset, length))
      {
      do stuff
      }
  }
  </code></pre>
  
  <p>Which generates the following error:</p>
  
  <p><code>Unhandled Exception: System.ArgumentException: capacity
    at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity) [0x00000] in &lt;filename unknown&gt;:0
    at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0
  [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: capacity
    at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in &lt;filename unknown&gt;:0
    at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity) [0x00000] in &lt;filename unknown&gt;:0
    at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0</code></p>
  
  <p>I've tried specifying and not specifying the capacity of the memory map as well as a lot of different values for the capacity from a couple of megabytes to the entire available ram on the board.  Anyone have tips for where to go from here?</p>