galford13x
galford13x

Reputation: 2531

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?

Upvotes: 1

Views: 621

Answers (1)

Chris Benard
Chris Benard

Reputation: 3215

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 Enabling

Upvotes: 2

Related Questions