Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C#
C# Reference
C# Compiler Options
C# Compiler Errors
 Compiler Error CS0122
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual C# Reference: Errors and Warnings 
Compiler Error CS0122 

Error Message

'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 Foo()
    {
    }
}

public class MyClass2
{
    public static int Main()
    {
        MyClass a = new MyClass();
        // Foo is private
        a.Foo();   // CS0122
        return 0;
   }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
OK, This comment says nothing! Can someone please explain what this error means!      V77   |   Edit   |   Show History

OK, This comment says nothing! Can someone please explain what this error means!

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0122: 'assessmentconfiguration.dbProviderName' is inaccessible due to its protection level

Source Error:

Line 33:     public static DbCommand CreateCommand()
Line 34:     {
Line 35:         string dataProviderName = assessmentconfiguration.dbProviderName;
Line 36:         string connectionString = assessmentconfiguration.dbConnectionString;
Line 37:         DbProviderFactory factory = DbProviderFactories.GetFactory(dataProviderName);

Source File: c:\Documents and Settings\My Documents\Visual Studio 2005\WebSites\WebSite7\App_Code\GenericDataAccess.cs Line: 35

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker