MethodAccessException Class
.NET Framework Class Library
MethodAccessException Class

The exception that is thrown when there is an invalid attempt to access a private or protected method inside a class.

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

This exception is typically thrown when the access level of a method in a class library is changed, and one or more assemblies referencing the library have not been recompiled.

MethodAccessException uses the HRESULT COR_E_METHODACCESS, that has the value 0x80131510.

For a list of initial property values for an instance of MethodAccessException, see the MethodAccessException constructors.

System..::.Object
  System..::.Exception
    System..::.SystemException
      System..::.MemberAccessException
        System..::.MethodAccessException
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

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
as_friend      Zolka   |   Edit   |   Show History
In Managed C++, if you have #using <assembly> as_friend in a cpp file, the compiler will reach the not-public types from the other assembly. However you will get MethodAccessException during runtime if you forget adding the InternalsVisibleTo attribute with the actual assembly name to that (friend) assembly. The Exception comes right before the method is called which is using an internal type.
Tags What's this?: jit (x) Add a tag
Flag as ContentBug
Processing
Page view tracker