I have found plenty of information out there about this error: \'ERROR: Could not load file or assembly \'*.dll\' or one of its dependencies. Access is denied.’ But i haven
I ran into this problem and it turned out that a referenced package/assembly was being encrypted by Windows. This happened because my company implemented a policy to require the My Documents folder to be encrypted and my Visual Studio solutions happened to be under that directory.
I could manually go into the file/directory properties in Windows Explorer and disable encryption. But in my case this was a temporary solution since the network policy would eventually change it back. I wound up moving my VS solution to another un-encrypted location.
To anyone else who tried most of the solutions and still having problems.
My solution is different from the others, which is located at the bottom of this post, but before you try it make sure you have exhausted the following lists. To be sure, I have tried all of them but to no avail.
Recompile and redeploy from scratch, don't update the existing app. SO Answer
Grant IIS_IUSRS full access to the directory "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files"
Keep in mind the framework version you are using. If your app is using impersonation, use that identity instead of IIS_IUSRS
Delete all contents of the directory "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files".
Keep in mind the framework version you are using
Change the identity of the AppPool that your app is using, from ApplicatonPoolIdentity to NetworkService.
IIS > Application Pools > Select current app pool > Advance Settings > Identity.
SO Answer (please restore to default if it doesn't work)
Verify IIS Version and AppPool .NET version compatibility with your app. Highly applicable to first time deployments. SO Answer
Verify impersonation configuration if applicable. SO Answer
My Solution:
I found out that certain anti-virus softwares are actively blocking compilations of DLLs within the directory "Temporary ASP.NET Files", mine was McAfee, the IT people failed to notify me of the installation.
As per advice by both McAfee experts and Microsoft, you need to exclude the directory "Temporary ASP.NET Files" in the real time scanning.
Sources:
Don't disable the Anti-Virus because it is only doing its job. Don't manually copy missing DLL files in the directory \Temporary ASP.NET Files{project name} because thats duct taping.