title: MemoryMappedFile.CreateFromFile always throws UnauthorizedAccessException
body: <p>I realize .NET 4.0 is in Beta, but I'm hoping someone has a resolution for this. I'm trying to create a memory mapped file from a DLL:</p>
  
  <pre><code>FileStream file = File.OpenRead("C:\mydll.dll");
  using (MemoryMappedFile mappedFile = MemoryMappedFile.CreateFromFile(file,
      "PEIMAGE", 1024 * 1024, MemoryMappedFileAccess.ReadExecute))
  {
      using (MemoryMappedViewStream viewStream = mappedFile.CreateViewStream())
      {
          // read from the view stream
      }
  }
  </code></pre>
  
  <p>Unfortunately, no matter what I do, I always get an <code>UnauthorizedAccessException</code>, for which the <a href="http://msdn.microsoft.com/en-us/library/dd267557(VS.100).aspx" rel="nofollow noreferrer">MSDN documentation</a> states:</p>
  
  <blockquote>
    <p>The operating system denied the specified access to the file; for example, access is set to Write or ReadWrite, but the file or directory is read-only.</p>
  </blockquote>
  
  <p>I've monitored my application with Sysinternals Process Monitor, which shows that the file is indeed being opened successfully. I've also tried memory mapping other non-DLL files, but with the same result.</p>