using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Form_Library { public partial class Login : Form { private int intAttemptCount = 0; private bool blnAllowClosing = false; private int intUserID; public delegate void _LoginFailed(Object sender, EventArgs e); public delegate void _LoginSucceeded(Object sender, LoginEventArgs e); public delegate void _LoginCancelled(Object sender, EventArgs e); public event _LoginFailed LoginFailed; public event _LoginSucceeded LoginSucceeded; public event _LoginCancelled LoginCancelled; public int UserID { get { return intUserID; } } public Login() { InitializeComponent(); } private void Login_Activated(object sender, EventArgs e) { txtusername.Text = Environment.UserName; txtpassword.Focus(); } private void Login_FormClosing(object sender, FormClosingEventArgs e) { if (!blnAllowClosing) { e.Cancel = true; } } private void btnok_Click(object sender, EventArgs e) { // Was a user name entered? if(txtusername.Text.Trim().Length > 0) { // Was the password correct? if(txtpassword.Text == "secret") { // Successful login, set the User ID intUserID = 27; // Raise the LoginSucceeded event if(this.LoginSucceeded != null) this.LoginSucceeded(this, new LoginEventArgs(intUserID)); // Turn on the allow closing flag blnAllowClosing = true; } else { // Inform the user // that the password was invalid MessageBox.Show("The password you entered" +" was invalid.","Login"); // Increment the attempt count intAttemptCount += 1; // Check the attempt count if (intAttemptCount == 3) { // Raise the LoginFailed event if(this.LoginFailed != null) this.LoginFailed(this, new EventArgs()); // Set the Cancel dialog result this.DialogResult = DialogResult.Cancel; // Turn on the allow closing flag blnAllowClosing = true; } } } else { // Inform the user // that they must supply a user name MessageBox.Show("You must supply a User Name.","Login"); // Was a user name entered? if (txtusername.Text.Trim().Length > 0) { // Was the password correct? if (txtpassword.Text == "secret") { // Successful login, set the User ID intUserID = 27; // Raise the LoginSucceeded event if (this.LoginSucceeded != null) this.LoginSucceeded(this, new LoginEventArgs(intUserID)); // Turn on the allow closing flag blnAllowClosing = true; } } else { // Inform the user // that the password was invalid MessageBox.Show("The password you entered" +" was invalid.", "Login"); // Increment the attempt count intAttemptCount += 1; // Check the attempt count if (intAttemptCount == 3) { // Raise the LoginFailed event if (this.LoginFailed != null) this.LoginFailed(this, new EventArgs()); // Set the Cancel dialog result this.DialogResult = DialogResult.Cancel; // Turn on the allow closing flag blnAllowClosing = true; } else { // Inform the user // that they must supply a user name MessageBox.Show("You must supply a User Name.", "Login"); } } } } private void btncancel_Click(object sender, EventArgs e) { // Raise the LoginCancelled event if (this.LoginCancelled != null) this.LoginCancelled(this, new EventArgs()); // Turn on the allow closing flag blnAllowClosing = true; // Raise the LoginCancelled event if (this.LoginCancelled != null) this.LoginCancelled(this, new EventArgs()); // Turn on the allow closing flag blnAllowClosing = true; } } }
می خواستم بدونم که چرا کد زیر که براتون گذاشتم هنگام اجرا کردن برنامه پیغام خطا میده ؟؟
کد نوشته شده صحیح است و من حتی Rebuild solution هم کردم پیغام successfulبه من داد ولی نمی دونم هنگام اجرا کردن برنامه پیغام خطا میده ؟؟
اینم متن خطا :
a project with on output type of class library can not be started directly in order to this project, add an executable project to this solution wich refrences the library project . set the executable project as the start up project
متن خطارا قرار دهید
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)