I’m relatively new to C# coding in the .NET framework. I’m using Visual studios 10.
I feel like this is a simple problem but whatever I seem to try with the visability, it doesn’t work. This is the “try” with the least errors. I wanted to split the classes to be separate from the windows application form code. Maybe that’s why it isn’t working properly as when I ran a first try all in one (messy) windows app form code, it worked. Now splitting it into a neater package it won’t. Please take a look at the code and tell me what I’m overlooking. I have searched the questions of course as well as googling, but the problem is that mostly this error has to do with arrays.
For me it does NOT.
Here is the error:
‘adm_LogOn’ is a ‘variable’ but is used like a ‘method’ DemoTestEditor\DemoTestEditor\Form1.cs
private void buttonAdmLogOn_Click(object sender, EventArgs e)
{
// The console commands (above and below Writes to the Output.
// Messagebox also works but I think it's too "in your face"
Console.WriteLine("Admin Log On Button pressed.");
AdminClasses adm_LogOn = new AdminClasses(); // Creates a new object instance myALogOn
this.admTicket = adm_LogOn(userName.Text, passWord.Text);
if (this.admTicket != null)
{
Console.WriteLine("Got Ticket: " + this.admTicket);
this.buttonAdmLogOn.Enabled = true;
this.buttonAdmLogOff.Enabled = false;
}
}
And this is the class it’s calling within the separate Admin.classes.cs code.
public string adm_LogOn(string username, string password)
{
// Initialize a (new object) adm service to work with.
SmartConnectionAdmin.SmartConnectionAdminService adm = new SmartConnectionAdmin.SmartConnectionAdminService();
// Setting up the arguments for the webservice (LogOnRequest) parameters
string ticket = null;
string server = null;
string clientName = "C# Client Suus";
string domain = null;
string clientAppName = "C# Tester Suus";
string clientAppVersion = null;
string clientAppSerial = null;
string clientAppCode = null;
try
{
// Place call with the above arguments
adm.LogOn(username, password, ref ticket, server, clientName, domain, clientAppName, clientAppVersion, clientAppSerial, clientAppCode);
// Displays the retrieved ticket
Console.WriteLine("The following ticket has been received: {0}", ticket);
}
catch (Exception e)
{
MessageBox.Show("Error: " + e.Message, "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Console.WriteLine("UserName checked.");
return ticket;
}
}
public string adm_LogOn(string username, string password)isn’t a class definition, it is a method (within a class). You will need to create the surrounding object if it doesn’t exist, then you can jsut call this method from the instance of that class.If this method is within the class you are currently using, you can just call the method, i.e. you can remove this line:
What you need to do is change it to this: