When I run my C# app, it shows the following error
Inconsistent accessibility: parameter type ‘timesheet.libs.DbObject’ is less accessible than method ‘timesheet.model.usertimesheet.usertimesheet(timesheet.libs.DbObject)’ C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\model\usertimesheet.cs
Inconsistent accessibility: parameter type ‘timesheet.libs.DbObject’ is less accessible than method ‘timesheet.MainFormMDI.setdbobject(timesheet.libs.DbObject)’ C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\MainFormMDI.cs
Inconsistent accessibility: parameter type ‘timesheet.libs.DbObject’ is less accessible than method ‘timesheet.model.user.user(timesheet.libs.DbObject)’ C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\model\user.cs
Inconsistent accessibility: parameter type ‘timesheet.libs.DbObject’ is less accessible than method ‘timesheet.model.project.project(timesheet.libs.DbObject)’ C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\model\project.cs
I have a snippet of login.cs as
MainFormMDI mainform = new MainFormMDI();
mainform.setdbobject(dbobject);
mainform.setuserobject(userobj);
mainform.Show();
MainFormMDI.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using timesheet.model;
using timesheet.libs;
namespace timesheet
{
public partial class MainFormMDI : Form
{
private DbObject dbobject;
private user userobj;
public MainFormMDI( )
{
InitializeComponent();
}
public void setdbobject(DbObject dbobject)
{
this.dbobject = dbobject;
}
public void setuserobject(user userobj)
{
this.userobj = userobj;
}
private void MainFormMDI_Load(object sender, EventArgs e)
{
}
private void adminPanelToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
}
I tried other solutions like changing the dbobject and user class to public but nothing changes. I want to pass the userobject and the dbobject to the MainFormMDI class to be able to carry out further actions on these objects. I will be happy to hear your fixes .
You need to make timesheet.libs.DbObject public. You then need to recompile the library (making an assumption that libs indicates it’s in a library) and then rebuild the project that uses it.
The problem is that DbObject is either private or internal and it’s being passed as a parameter to a public method. If the method is public, then all it parameter types must be as well.