I have a 3rd party dll which when used in my local VS was working perfectly without any issues. This 3rd party dll came with 32bit and 64 bit dll installation files. I ran the 64bit installer and the system32 folder had the dll required. My local project had no trouble calling these dll's.
When I tried the same step to host the website on IIS 7.0 on 64bit windows 2012 R2 testing server, I was getting the following error : Unable to load DLL '3rdparty.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
To fix this i tried uninstalling the 64bit and installed the 32 bit dll's and SysWow64 had the dll's required and no error was received.
I checked if system32 had those dlls but there was none and only syswow64 had the dll's. Can any one tell me why 32 bit dll's worked on the server and 64bit on my local ?
Also when trying on different machines I found 32 bit installer worked on all but 64 bit had issues on some machines.
Adding to this strangeness, when I hosted a copy of same website on different folder however under same application pool of IIS 7.0 on the testing server. I received the error on one website while the other had no issue loading the dll's required. Both these website had everything same in terms of IIS user used, access rights only difference was they were under different folder structure.
Also is there any way of referencing 3rd party dll to use particular path rather than trusting system32 and syswow64 folders in website projects.
As mentioned by Cyril I used Procmon to track where the asp.net website was looking for the 3rd party dll. On checking it was found that 3rd party dll was being looked at SysWow64 folder rather than on anticipated folder that is System32. This was happening because the website before copying was compiled on 32 bit version and hence copied version was looking for 32 bit and not 64 bit. This was making it to behave differently. However I need to understand how does the .net compiler decide to use which version to get to the bottom of this confusion that I have.
Following question also helped: Dll in both the bin and the gac, which one gets used?