I am developing a School Management System in Asp.net and C#. I have created a login page when i click to login an error occoured that Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error:
public string connectionString()
{
string connString = ConfigurationManager.ConnectionStrings["SchoolConnectionString1"].ConnectionString;
return connString;
}
Source File: C:\Users\ALI\Desktop\Final Project\SchoolERP\SchoolERP\Connection\MyConnection.cs Line: 14
My Stack Trace is given under
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] SchoolERP.Connection.MyConnection.connectionString() in C:\Users\ALI\Desktop\Final SchoolERP.Connection.MyConnection.connectionString() in C:\Users\ALI\Desktop\Final Project\SchoolERP\SchoolERP\Connection\MyConnection.cs:14 SchoolERP.Pages.Membership.Logout.btnLogout_Click(Object sender, EventArgs e) in C:\Users\ALI\Desktop\Final Project\SchoolERP\SchoolERP\Pages\Membership\Logout.aspx.cs:26 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563