UnauthorizedAccessException Class
This page is specific to:.NET Framework Version:1.12.03.03.5Silverlight 34.0
.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)
Syntax

'Usage

Dim instance As UnauthorizedAccessException

'Declaration

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class UnauthorizedAccessException _
    Inherits SystemException
Remarks

The reasons for the exception can be found in the details of the exception object. For more information, see Use the Exception Assistant.

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

Inheritance Hierarchy

System..::.Object
  System..::.Exception
    System..::.SystemException
      System..::.UnauthorizedAccessException
        System.Security.AccessControl..::.PrivilegeNotHeldException
Thread Safety

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

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.
Version Information

.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
See Also

Reference

Other Resources

Community Content

Possible Fix
Added by:paulcalabro
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.
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View