title: Windows Vista: Unable to load DLL 'x.dll': Invalid access to memory location. (DllNotFoundException)
body: <p>I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results).</p>
  
  <p>We make use of a .DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is <a href="http://www.azsdk.com/hardwareid.html" rel="nofollow noreferrer">This from AzSdk</a>. 
  In fact, this works perfectly under Windows XP. However, for some strange reason, inside our project (way bigger), we get this exception: </p>
  
  <pre><code>Exception Type:        System.DllNotFoundException
  Exception Message:     Unable to load DLL 'HardwareID.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)
  Exception Target Site: GetHardwareID
  </code></pre>
  
  <p>I don't know what can be causing the problem, since I have full control over the folder. The project is a c#.net Windows Forms application and everything works fine, except the call for the external library. </p>
  
  <p>I am declaring it like this: (note: it's <em>not</em> a COM library and it doesn't need to be registered).</p>
  
  <pre><code>[DllImport("HardwareID.dll")]
  public static extern String GetHardwareID(bool HDD,
     bool NIC, bool CPU, bool BIOS, string sRegistrationCode);
  </code></pre>
  
  <p>And then the calling code is quite simple:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      textBox1.Text = GetHardwareID(cb_HDD.Checked, 
                                    cb_NIC.Checked, 
                                    cb_CPU.Checked, 
                                    cb_BIOS.Checked, 
                                   "*Registration Code*");
  }
  </code></pre>
  
  <p>When you create a sample application, it works, but inside my projectit doesn't. Under XP works fine. Any ideas about what should I do in Vista to make this work? 
  As I've said, the folder and its sub-folders have Full Control for "Everybody". </p>
  
  <p><strong>UPDATE:</strong> I do not have Vista SP 1 installed. </p>
  
  <p><strong>UPDATE 2:</strong> I have installed Vista SP1 and now, with UAC disabled, not even the simple sample works!!! :( Damn Vista.</p>