.NET FrameworkでのC#コーディングは比較的初めてです。Visual Studios 10を使用しています。これは単純な問題のように感じますが、視認性を試してみても機能しません。これは、エラーが最も少ない「試行」です。クラスを分割して、Windowsアプリケーションのフォームコードから分離したかったのです。たぶんそれが正しく機能していない理由です。最初にすべてを1つの(厄介な)Windowsアプリフォームコードで試したとき、機能しました。今ではそれをきちんとしたパッケージに分割します。コードを見て、私が見落としているものを教えてください。もちろん、グーグルだけでなく質問も検索しましたが、問題は、ほとんどの場合、このエラーが配列に関係していることです。私にとってはそうではありません。
エラーは次のとおりです。
「adm_LogOn」は「変数」ですが、「メソッド」のように使用されます。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;
}
}
そして、これは別のAdmin.classes.csコード内で呼び出しているクラスです。
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;
}
}