UnauthorizedAccessException Class
.NET Framework Class Library
UnauthorizedAccessException Class

The exception that is thrown when the operating system denies access because of an I/O error or a specific type of security error.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class UnauthorizedAccessException _
    Inherits SystemException
Visual Basic (Usage)
Dim instance As UnauthorizedAccessException
C#
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class UnauthorizedAccessException : SystemException
Visual C++
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class UnauthorizedAccessException : public SystemException
JScript
public class UnauthorizedAccessException extends SystemException

The reasons for the exception can be found in the details of the exception object. For more information, see Find Out More About an Exception with the Exception Assistant.

UnauthorizedAccessException uses the HRESULT COR_E_UNAUTHORIZEDACCESS, which has the value 0x80070005.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Possible Fix      paulcalabro   |   Edit   |   Show History
I was getting this error because I had setup Windows on my D: drive (opposed to the C: drive).
My old installation had the 3.5 framework.
The fact that the path to the files is "hard-coded" probably had my apps looking at this old Windows installation, causing it to incorrectly error.
Also, whenever I tried to reinstall it detected it being already installed (probably because it was looking in the wrong location).

The error was because... one account didn't have access to this c: drive where these needed files were located.
Giving permissions to that account got rid of the IO problem.
I figured out the solution due to this post:


Description
Hello,

after installing Visual Studio "Orcas" on my machine I noticed an error when creating a new WPF project: the default XAML page displayed a "whoops" error mentioning that the required assemblies for the Window and Grid class weren't referenced.

After further investigation I found out that the path to the .NET Framework 3.5 files doesn't depend on the HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir registry key to get the program files folder but instead uses "C:\Program Files".

Because of space issuses I recently changed this registry key to point to "D:\Programme" (including lots of other changes that aren't interesting in this case).

So the problem was that the project was created with a reference to "D:\Programme\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" (respecting the registry key) but the assembly was installed to "C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" (not respecting the registry key) which caused "Orcas" to struggle.

Copying all the files from "C:\Program Files\Reference Assemblies\" to "D:\Programme\Reference Assemblies\" solved the problem.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
Page view tracker