I am getting an error message that is throwing me for a loop. Basiclly I am setting the value of a bool property in the constructor of a class (the same class that the property is in). As soon as I try to set the value I get
Exception of type System.StackOverflowException was thrown.
The constructor is overloaded. Below are the overloads.
#region overloaded constructors
public GetLabelParams(string StoredProcedure, string connections)
{
spname = StoredProcedure;
HasError = false;
//set the datatable to null because no parameters are passed with this
//constructor
dtParamTypes = new DataTable();
//set connnection name to enum sent from calling code
connectionname = connections;
//connect to the database and stored procedure specified.
try
{
connection = ConfigurationSettings.AppSettings[connections.ToString()];
}
catch(Exception ex)
{
error = error + "The " + connectionname + " information was not found in the web.config file <br> Server error <br>" +
ex.Message;
HasError = true;
}
}
//overloaded constructor for receiving a Datatable of parameters
//and types for each parameter. The Datatable has 4 columns.
//parameter names, parameter values, parameter type, and value
public GetLabelParams(string StoredProcedure, string connections, DataTable ParamsAndTypes)
{
spname = StoredProcedure;
connectionname = connections;
//set the has errors property to false on class instantiation
HasError = false;
//connect to the database and stored procedure specified.
try
{
connection = ConfigurationSettings.AppSettings[connections.ToString()];
}
catch(Exception ex)
{
error = error + "The " + connectionname + " information was not found in the web.config file <br> Server error <br>" +
ex.Message;
HasError = true;
}
dtParamTypes = new DataTable();
dtParamTypes = ParamsAndTypes;
}
#endregion
As soon as I set the HasError property to false the error is thrown. Here are my properties.
#region error properties
/// <summary>
/// This is the error property called by the main code.
/// </summary>
public bool HasError
{
get
{
return HasError;
}
set
{
HasError = value;
}
}
public string errors
{
get
{
return error;
}
}
#endregion
This seems so straight forward I am not sure what the problem is. I have tried to delete the dlls and recompile. I have tried renaming the property. I have tried refrencing the property by this.HasError. Any suggestions would be great.
Exception of type System.StackOverflowException was thrown.
The constructor is overloaded. Below are the overloads.
#region overloaded constructors
public GetLabelParams(string StoredProcedure, string connections)
{
spname = StoredProcedure;
HasError = false;
//set the datatable to null because no parameters are passed with this
//constructor
dtParamTypes = new DataTable();
//set connnection name to enum sent from calling code
connectionname = connections;
//connect to the database and stored procedure specified.
try
{
connection = ConfigurationSettings.AppSettings[connections.ToString()];
}
catch(Exception ex)
{
error = error + "The " + connectionname + " information was not found in the web.config file <br> Server error <br>" +
ex.Message;
HasError = true;
}
}
//overloaded constructor for receiving a Datatable of parameters
//and types for each parameter. The Datatable has 4 columns.
//parameter names, parameter values, parameter type, and value
public GetLabelParams(string StoredProcedure, string connections, DataTable ParamsAndTypes)
{
spname = StoredProcedure;
connectionname = connections;
//set the has errors property to false on class instantiation
HasError = false;
//connect to the database and stored procedure specified.
try
{
connection = ConfigurationSettings.AppSettings[connections.ToString()];
}
catch(Exception ex)
{
error = error + "The " + connectionname + " information was not found in the web.config file <br> Server error <br>" +
ex.Message;
HasError = true;
}
dtParamTypes = new DataTable();
dtParamTypes = ParamsAndTypes;
}
#endregion
As soon as I set the HasError property to false the error is thrown. Here are my properties.
#region error properties
/// <summary>
/// This is the error property called by the main code.
/// </summary>
public bool HasError
{
get
{
return HasError;
}
set
{
HasError = value;
}
}
public string errors
{
get
{
return error;
}
}
#endregion
This seems so straight forward I am not sure what the problem is. I have tried to delete the dlls and recompile. I have tried renaming the property. I have tried refrencing the property by this.HasError. Any suggestions would be great.