Nazgul
Nazgul

Reputation: 2004

System.UnauthorizedAccessException when running a test in VS2008

When I run selenium tests (written as nunit tests) from VS2008 I am getting:

System.UnauthorizedAccessException : Access to the path /bin/Debug is denied.

The test is trying to read an entry in App.Config. This file is copied to bin/Debug during compilation.

I used unlocker to check file handles and it is VS2008 that has a handle to that file.

Upvotes: 4

Views: 8711

Answers (2)

Blake
Blake

Reputation: 2397

I was having the same problem. The way I got around it was by starting Visual Studio with Administrator privileges (right click on visual studio --> run as Administrator). I then re-opened the solution and ran my tests. This time they passed.

Upvotes: 3

Paul Lalonde
Paul Lalonde

Reputation: 5050

You need to change your test configuration so that access to the directory is allowed. See Test/Edit Test Run Configurations/Deployment.

If you are trying to read or write a file in that directory, you will probably need to copy it to the directory where the test is run. Again, the Deployment tab of the test run config dialog will help you out.

Upvotes: 1

Related Questions