<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>

[{'answer_id': 29313, 'author': 'Dale Ragan', 'author_id': 1117, 'author_profile': 'https://Stackoverflow.com/users/1117', 'pm_score': 1, 'selected': False, 'text': '<p>Is the machine you have the code deployed on a 64-bit machine?  You could also be running into a <a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention" rel="nofollow noreferrer">DEP</a> issue.</p>\n\n<p>Edit</p>\n\n<blockquote>\n  <p>This is a 1st gen Macbook Pro with a 1st gen Core Duo 2 Intel processor. Far from 64 bits.</p>\n</blockquote>\n\n<p>I mentioned 64 bit, because at low levels structs from 32 bit to 64 bit do not get properly handled.  Since the machines aren\'t 64bit, then more than likely disabling DEP would be a good logical next step.  Vista did get more secure than XP SP2.</p>\n\n<blockquote>\n  <p>Well, I\'ve just turned DEP globally off to no avail. Same error.</p>\n</blockquote>\n\n<p>Well, I also read that people were getting this error after updating a machine to Vista SP1.  Do these Vista installs have SP1 on them? </p>\n\n<blockquote>\n  <p>Turns out to be something completely different. Just for the sake of testing, I\'ve disabled de UAC (note: I was not getting any prompt).</p>\n</blockquote>\n\n<p>Great, I was actually going to suggest that, but I figured you probably tried it already.</p>\n'}, {'answer_id': 29367, 'author': 'Curt Hagenlocher', 'author_id': 533, 'author_profile': 'https://Stackoverflow.com/users/533', 'pm_score': 0, 'selected': False, 'text': "<p>Have you made a support request to the vendor?  Perhaps there's something about the MacBook Pro hardware that prevents the product from working.</p>\n"}, {'answer_id': 29371, 'author': 'imaginaryboy', 'author_id': 2508, 'author_profile': 'https://Stackoverflow.com/users/2508', 'pm_score': 0, 'selected': False, 'text': '<p>Given that the exception is a DllNotFoundException, you might want to try checking the HardwareID.dll with <a href="http://www.dependencywalker.com/" rel="nofollow noreferrer">Dependency Walker</a> BEFORE installing any dev tools on the Vista install to see if there is in fact a dependency missing.</p>\n'}, {'answer_id': 29757, 'author': 'Will Dean', 'author_id': 987, 'author_profile': 'https://Stackoverflow.com/users/987', 'pm_score': 2, 'selected': False, 'text': "<blockquote>\n  <p>Unable to load DLL 'HardwareID.dll':\n  Invalid access to memory location.\n  (Exception from HRESULT: 0x800703E6)</p>\n</blockquote>\n\n<p>The name of DllNotFoundException is confusing you - this isn't a problem with finding or loading the DLL file, the problem is that when the DLL is loaded, it does an illegal memory access which causes the loading process to fail.</p>\n\n<p>Like another poster here, I think this is a DEP problem, and that your UAC, etc, changes have finally allowed you to disable DEP for this application.</p>\n"}, {'answer_id': 29789, 'author': 'Wilka', 'author_id': 1367, 'author_profile': 'https://Stackoverflow.com/users/1367', 'pm_score': 3, 'selected': True, 'text': '<p>@<a href="https://stackoverflow.com/questions/29284/windows-vista-unable-to-load-dll-xdll-invalid-access-to-memory-location-dllnotf#29400">Martín</a></p>\n\n<p>The reason you were not getting the UAC prompt is because UAC can only change how a process is <strong>started</strong>, once the process is running it must stay at the same elevation level. The UAC will prompt will happen if:</p>\n\n<ul>\n<li>Vista thinks it\'s an installer (<a href="http://msdn.microsoft.com/en-us/library/aa905330.aspx#wvduac_topic3" rel="nofollow noreferrer">lots of rules here</a>, the simplest one is if it\'s called "setup.exe"), </li>\n<li>If it\'s flagged as "Run as Administrator" (you can edit this by changing the properties of the shortcut or the exe), or </li>\n<li>If the exe contains a manifest requesting admin privileges.</li>\n</ul>\n\n<p>The first two options are workarounds for \'legacy\' applications that were around before UAC, the correct way to do it for new applications is to <a href="http://msdn.microsoft.com/en-us/library/bb756929.aspx" rel="nofollow noreferrer">embed a manifest resource</a> asking for the privileges that you need.</p>\n\n<p>Some program, such as <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">Process Explorer</a> appear to elevate a running process (when you choose "Show details for all process" in the file menu in this case) but what they really do is start a new instance, and it\'s that new instance that gets elevated - not the one that was originally running. This is the recommend way of doing it if only some parts of your application need elevation (e.g. a special \'admin options\' dialog).</p>\n'}, {'answer_id': 30886, 'author': 'imaginaryboy', 'author_id': 2508, 'author_profile': 'https://Stackoverflow.com/users/2508', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n<blockquote>\n<p>In addition to allowing full control to &quot;Everyone&quot; does the location also allow processes with a medium integrity level to write?</p>\n</blockquote>\n<p>How do I check that ? I am new to Vista, I don't like it too much, it's too slow inside a VM for daily work and for VStudio usage inside a Virtual Machine, it doesn't bring anything new.</p>\n</blockquote>\n<p>From a command prompt to you can execute:</p>\n<pre><code>icacls C:\\Folder\n</code></pre>\n<p>If you see a line such as &quot;Mandatory Label\\High Mandatory Level&quot; then the folder is only accessible to a high integrity process.  If there is no such line then medium integrity processes can access it provided there are no other ACLs denying access (based on user for example).</p>\n<p>EDIT: Forgot to mention you can use the /setintegritylevel switch to actually change the required integrity level for accessing the object.</p>\n"}]
['https://Stackoverflow.com/questions/29284', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2684/']