Could not load file or assembly or one of its dependencies. Access is denied. The issue is random, but after it happens once, it continues

后端 未结 20 1648
夕颜
夕颜 2020-12-02 09:32

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

相关标签:
20条回答
  • 2020-12-02 10:27

    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.

    0 讨论(0)
  • 2020-12-02 10:28

    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.

    1. Recompile and redeploy from scratch, don't update the existing app. SO Answer

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

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

    4. 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)

    5. Verify IIS Version and AppPool .NET version compatibility with your app. Highly applicable to first time deployments. SO Answer

    6. 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:

    • McAfee Support Forum
    • Microsoft Support
    • Asp.Net Forum

    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.

    0 讨论(0)
提交回复
热议问题