简体   繁体   中英

First Chance Exception access to path is denied (UnauthorizedAccessException)

I am running an application in Debug mode but I noticed after a few seconds, a First Chance Exception of type 'System.UnauthorizedAccessException' was being thrown very often and continuously. While this didn't prevent my application from running, I still wanted to understand what was going on and resolve the issue to help with performance.

It turns out the exception is "Access to the path 'XXX.dll' is denied". This baffles me as it must be coming from windows when the application is attempting to access the DLL, which it must have already done successfully.

Running the application multiple times will cause the error to occur on different DLLs so the exact position in the application where this occurs is not deterministic or repeatable.

Is there a way to resolve this issue? Why is it occurring?

Assembly Binding Logs

If you think it might be related to assembly binding, use Scott Hanselman's instructions to enable FusionLog and view the assembly binding logs.

It will probably help you find and solve your problem, if it is related to assembly binding.

Alternatively, just set the Registry keys your self. (I just memorized them, as I set them all the time.) Set HKLM\\Software\\Microsoft\\Fusion\\ForceLog registry value to 1 and HKLM\\Software\\Microsoft\\Fusion\\LogPath registry value to C:\\FusionLogs or some path that exists.

Example

支持FusionLog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM