Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'member' is inaccessible due to its protection level
The access modifier for a class member prevents accessing the member. For more information, see Access Modifiers (C# Programming Guide).
One cause of this (not shown in the sample below) can be omitting the /out compiler flag on the target of a friend assembly. For more information, see Friend Assemblies (C# Programming Guide) and /out (Set Output File Name) (C# Compiler Options)
Example
The following sample generates CS0122:
// CS0122.cs
public class MyClass
{
// Make public to resolve CS0122
void MyMethod()
{
}
}
public class MyClass2
{
public static int Main()
{
MyClass a = new MyClass();
// MyMethod is private
a.MyMethod(); // CS0122
return 0;
}
}