I have run into this weird problem. In my WCF project I have referenced a class library that uses SQLite to query some static data. Naturally that class library is using System.Data.Sqlite + System.Data.SQLite.Core + System.Data.SQLite.EF6 + System.Data.SQLite.Linq from NuGet. The WCF project itself does not do the query. It invokes a method from the class library that does it.
When I run it on my dev machine all is well. But after I deployed it to IIS on a Windows Server 2012, the exception
Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) was thrown. I did search SO and found that I need to reference at least System.Data.SQLite.Core in my main WCF project and make sure it has x64 & x86 folders with the corresponding Sqlite.Interop.dll in each folder respectively. The said folders are auto-generated with the NuGet reference and are placed under bin folder. So I was happy. Deployed. And same thing happened: all is well in dev machine then unable to load DLL on the server.
I even tried referencing all NuGet packages in main WCF project to no avail. Then it occurred to me to try manually copying the dll from x64 folder to my bin root folder, right alongside wcf.dll and System.Data.SQLite.dll. Now the error message changed to
Unable to load DLL 'SQLite.Interop.dll': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) instead of not found.
After giving it all permissions, it worked!
But this behaviour strikes me as strange because in my dev machine and another test server I cannot reproduce this. Only on the prod server would this error be thrown.
Is there anything that I've overlooked? BTW I tried to turn my WCF project from targeting AnyCPU to x64 only. I tried using Enable 32-bit in the advanced setting of IIS AppPool. None worked until all DLLs are in bin root.
Now it looks like it falls onto the permission realm. On Test environment and my dev machine the AppPool has god's privilege so the problem can't be reproduced.
TL;DR Then I went into the permission detail. I found that WCF apppool identity has Read permission only on x86\Sqlite.Interop.dll. I added the Read and execute and problem gone. You millage may vary and it could be the x64 one that needs permission.
After thoughts: Now I'll take a few days to observe but I think that this is it. Although from procmon it says Create File failed it doesn't mean it requires write permission.
Further testing showed my permission setting was off because I used the Visual Studio Deploy feature to deploy my website. In the process it sets my website root directory to Read only.
User contributions licensed under CC BY-SA 3.0