Inconsistent Availability Problem

I follow the Rob Conery MVC Storefront exercise series and get an inconsistent accessibility error from the following public SqlCatalogRepository (DB dataContext) constructor:

public class SqlCatalogRepository : ICatalogRepository
{
    DB db;

    public SqlCatalogRepository()
    {
        db = new DB();
        //turn off change tracking
        db.ObjectTrackingEnabled = false;
    }


    public SqlCatalogRepository(DB dataContext)
    {
        //override the current context
        //with the one passed in
        db = dataContext;
    }

Here is the error message: Error 1 Inconsistent availability: the parameter type "SqlRepository.DB" is less accessible than the method. Data.SqlCatalogRepository.SqlCatalogRepository (SqlRepository.DB) '

+3
source share
3 answers

Your class is DBnot public, so you cannot create a method public(or constructor) that takes it as a parameter. (What would subscribers call outside of your assembly?)

DB public, SqlCatalogRepository ( ) internal.

, .
SqlCatalogRepository , internal. (internal , )

, , public, internal.

DB , DB public.

+12

DB . DB .

+4

Check the accessor in the DB class (you don't see it here), it must be an open class in oreder so that it can be passed to the overloaded constructor.

+2
source

Source: https://habr.com/ru/post/1730048/


All Articles