Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复C#中的不可访问性错误`_C# - Fatal编程技术网

如何修复C#中的不可访问性错误`

如何修复C#中的不可访问性错误`,c#,C#,当我运行我的C#应用程序时,它显示以下错误 可访问性不一致:参数类型“timesheet.libs.DbObject”的可访问性不如方法“timesheet.model.usertimesheet.usertimesheet(timesheet.libs.DbObject)”C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\model\usertimesheet.cs 可访问性不一致:参数类型“timesheet.libs

当我运行我的C#应用程序时,它显示以下错误

可访问性不一致:参数类型“timesheet.libs.DbObject”的可访问性不如方法“timesheet.model.usertimesheet.usertimesheet(timesheet.libs.DbObject)”C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\model\usertimesheet.cs

可访问性不一致:参数类型“timesheet.libs.DbObject”的可访问性不如方法“timesheet.MainFormMDI.setdbobject(timesheet.libs.DbObject)”C:\Users\user\Desktop\Interface+code\Interface+code\timesheet\MainFormMDI.cs

可访问性不一致:参数类型“timesheet.libs.DbObject”的可访问性不如方法“timesheet.model.user.user(timesheet.libs.DbObject)”C:\Users\user\Desktop\Interface+code\timesheet\model\user.cs

可访问性不一致:参数类型“timesheet.libs.DbObject”的可访问性不如方法“timesheet.model.project.project(timesheet.libs.DbObject)”C:\Users\user\Desktop\Interface+code\Interface\code\timesheet\model\project.cs

我有一段login.cs作为

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)
        {
        }
    }
}

我尝试了其他解决方案,比如将dbobject和user类更改为public,但没有任何改变。我想将userobject和dbobject传递给MainFormMDI类,以便能够对这些对象执行进一步的操作。我很高兴听到您的修复。

您需要将timesheet.libs.DbObject公开。然后需要重新编译库(假设libs指示它在库中),然后重建使用它的项目


问题是DbObject要么是私有的,要么是内部的,并且作为参数传递给公共方法。如果该方法是公共的,则所有it参数类型也必须是公共的。

您需要将timesheet.libs.DbObject设置为公共的。然后需要重新编译库(假设libs指示它在库中),然后重建使用它的项目


问题是DbObject要么是私有的,要么是内部的,并且作为参数传递给公共方法。如果该方法是公共的,那么所有的it参数类型也必须是公共的。

它应该可以工作。您要传递的
dbobject
来自哪里?它的可访问性是什么?我想您需要在
timesheet.libs
中向我们展示相关的代码。我的答案是否解决了您的问题?应该可以。您要传递的
dbobject
来自哪里?它的可访问性是什么?我想您需要在
时间表.libs
中向我们显示相关代码。我的答案是否解决了您的问题?听起来确实如此。听起来确实如此。