我遇到了一点问题,似乎无法解决,有人可以帮助我,
这些是错误:
错误 1 可访问性不一致:字段类型“Flashloader.Toepassing”的可访问性低于字段“Flashloader.NewApplication.Toepassing”
错误 2 可访问性不一致:参数类型“Flashloader.toepassinginifile”的可访问性低于方法“Flashloader.NewApplication.NewApplication(Flashloader.toepassinginifile)”
因此,在这种情况下,那些错误但有来源的地方非常有用。
源 1 新应用程序(这是一个 Winform):
namespace Flashloader{
public partial class NewApplication : Form
{
private toepassinginifile _toepassinginifile;
//private controllerinifile _controlIniFile;
public Toepassing toepassing = new Toepassing();
public NewApplication(toepassinginifile iniFile)
{
_toepassinginifile = iniFile;
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Srec Files (.a20; .a21; .a26; .a44)|*.a20; *.a21; *.a26; *.a44|All files (*.*)|*.*";
openFileDialog1.Title = ("Choose a file");
openFileDialog1.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory());
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
fileBox.Text = (System.IO.Path.GetFileName(openFileDialog1.FileName));
}
}
private void button3_Click(object sender, EventArgs e)
{
toepassing.Name = nameBox.Text;
toepassing.Controller = controllerComboBox.SelectedItem;
toepassing.TabTip = descBox.Text;
toepassing.Lastfile = openFileDialog1.FileName;
fileBox.Text = openFileDialog1.FileName;
if (nameBox.Text == "")
MessageBox.Show("You haven't assigned a Name");
else if (controllerComboBox.Text == "")
MessageBox.Show("You haven't assigned a Controller");
else if (descBox.Text == "")
MessageBox.Show("You haven't assigned a Desciption");
else if (fileBox.Text == "")
MessageBox.Show("You haven't assigned a Applicationfile");
_toepassinginifile.ToePassingen.Add(toepassing);
_toepassinginifile.Save();
MessageBox.Show("Save Succesfull");
this.Close();
}
}}
源 2 flashloader.toepassing 文件(这是一个类):
namespace Flashloader{
class Toepassing
{
private String _name;
public String Name
{
get { return _name; }
set { _name = value; }
}
public Controller Controller = null;
public String TabTip = "";
public String Lastfile = "";
[Obsolete]
public String Baudrate = "";
[Obsolete]
public String Port = "";
public String Useboot = "";
public Toepassing()
{
Name = "";
}
public Toepassing(String naam)
{
Name = naam;
}
public override String ToString()
{
return Name + " :" + TabTip;
}
}
}
最后是 source 3 flashloader.toepassinginifile(另一个类):
namespace Flashloader
{
class toepassinginifile
{
private const String FILE_NAME = "flash.ini";
private Controllerlist _controllers;
public Toepassinglist ToePassingen { get; private set; }
public Settings Settings { get; private set; }
public toepassinginifile( Controllerlist controllers)
{
_controllers = controllers;
// TODO Startup class maken en laden
ToePassingen = LoadToepassingen();
}
private Toepassinglist LoadToepassingen()
{
StringList input = new StringList().FromFile( FILE_NAME );
Toepassinglist output = new Toepassinglist();
Settings settings = null;
Toepassing toepassing = null;
foreach (var item in input)
{
String line = item.Trim();
if (line.StartsWith("[") && line.EndsWith("]"))
{
settings = null;
toepassing = null;
String name = line.Substring(1, line.Length - 2);
if (name.ToUpper().Equals("STARTUP"))
{
Settings = settings = new Settings();
continue;
}
// TODO kan weg in de toekomst
if ( name.ToUpper().Equals("DRAG && DROP"))
{
toepassing = null;
continue;
} // */
toepassing = new Toepassing(name);
output.Add(toepassing);
}
else if (settings != null)
{
int index = line.IndexOf('=');
if (index < 0)
continue;
String key = line.Substring(0, index).Trim();
String value = line.Substring(index + 1).Trim();
if (Utils.EqualsIgnoreCase(key, "Baudrate"))
Settings.Baudrate = value;
else if (Utils.EqualsIgnoreCase(key, "Port"))
Settings.Port = value;
}
else if (toepassing != null)
{
int index = line.IndexOf('=');
if (index < 0)
continue;
String key = line.Substring(0, index).Trim();
String value = line.Substring(index + 1).Trim();
if (Utils.EqualsIgnoreCase(key, "TabTip"))
toepassing.TabTip = value;
else if (Utils.EqualsIgnoreCase(key, "Controller"))
toepassing.Controller = _controllers.FindByName(value);
else if (Utils.EqualsIgnoreCase(key, "Lastfile"))
toepassing.Lastfile = value;
else if (Utils.EqualsIgnoreCase(key, "Useboot"))
toepassing.Useboot = value;
}
}
return output;
}
public void Save()
{
StringList list = new StringList();
Toepassing settings = new Toepassing("[Startup]");
list.Add("["+settings.Name+"]");
list.Add("LastUsed=");
list.Add("Port=" +settings.Port);
list.Add("Baudrate=" +settings.Baudrate);
foreach (Toepassing item in ToePassingen)
{
list.Add( "[" + item.Name + "]" );
list.Add( "Controller=" + item.Controller.Name );
list.Add( "TabTip="+ item.TabTip );
list.Add("LastFile="+ item.Lastfile);
list.Add("UseBoot="+ item.Useboot);
}
Toepassing dragndrop = new Toepassing("[Drag && Drop]");
list.Add("["+dragndrop.Name+"]");
list.Add("Autostart=");
list.Add("Baudrate="+ dragndrop.Baudrate);
list.Add("Port="+ dragndrop.Port);
list.Add("Lasfile="+ dragndrop.Lastfile);
list.ToFile(FILE_NAME);
}
}
}
如果我能得到一些帮助,解决错误会容易得多。
修复