I'm using the [DllImport]
attribute to import a native DLL into my application but the DLL it's loading isn't in the local bin folder. It's being loaded from elsewhere on the system, but I can't work out where.
It works on my dev machine but not on a clean one.
I've enabled Fusion logging and that only shows me managed assemblies.
I've dumped the process using Sysinternals Process Explorer and that's telling me it's in C:\Windows\System32
but I can't see the file there in Windows Explorer.
It might be worth noting that I'm running 64 bit Windows 7 but the DLL only supports x86 so I've had to force my app do be x86. Is there some sort of redirect that changes where x86 files are loaded from?
The DllImport is a custom Silicon Labs USB driver. [DllImport("SiUSBXp.dll")]
I've also used the command prompt to do a dir si*
in the System32 folder and the file isn't there.
The File System Redirector will be kicking in:
The %windir%\System32 directory is reserved for 64-bit applications. Most DLL file names were not changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a different directory. WOW64 hides this difference by using a file system redirector.
In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64.
So even though the process thinks it loaded the DLL from System32
, it probably loaded from SysWOW64
And yes, the numbers are the wrong way around from what you'd expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With