I made a web proyect, and in all the preview codes compiling (F5) i was abble to test and continue using my programs and codes, after I finished it... i need to publish my web app, y have 4 Main classes, Bussines,Data,Entity and Visual, after this i compile my entire proyect, and try to publish it, i already conect my app to the DB and APP server because my Connection String it's already defined to acces that server in test mode and it works with no problem, the problem it's after i publish my proyect y got a StackOverflowException at SqlConnection.Open() but only by publishing it, can someone help me to figure out why it's happening this?
Here it's my code with the exception: Error Capture Debug
//Funcion Conectar
public SqlConnection conectar()
{
SqlConnecti
on cn = new SqlConnection();
//cn.ConnectionString = @"Data Source=LAP\YRG_LOCAL; Initial Catalog= SAP3Test; Integrated Security=true";
//cn.ConnectionString = @"Data Source=SERVER\SQLSERVER2008; Initial Catalog= SAP3Test; Integrated Security=true";
//Cn.ConnectionString = @"Data Source=MEXMAC176AP12\SQLSERVER2008; Initial Catalog= SAP3Test; user=sa password=E1nste1n01 Integrated Security=true";
cn.ConnectionString = @"Data Source=SERVER\YRGSQL2008R2; Initial Catalog= SAP3; Integrated Security=true; ";
return cn;
}
//Función para crear registro en Bitácora con sobrecarga
public static int CrearBitacora(String Sys, String pagWeb, int RESULTADO, String display) //sobrecarga cuando no se puede enviar objeto tipo entUsuario
{
//Declaración de objetos que se usaran, Res como , SQLCMD y un DATAREADER
//entUsuario obj = null;
SqlCommand cmd = null;
SqlDataReader dr = null;
int RES = 0;
try
{
Conexion cn = new Conexion(); // Variable de conexión para BD
SqlConnection cnx = cn.conectar();
cmd = new SqlCommand("CrearBitacora", cnx);
cmd.Parameters.AddWithValue("@idUsuario", "System");
cmd.Parameters.AddWithValue("@paginaWeb", pagWeb);
cmd.Parameters.AddWithValue("@tipoAccion", RESULTADO);//Se obtendrá de BD como parte del resultado
cmd.Parameters.AddWithValue("@Mensaje", display);//Mensaje que se mostró al Usuario
cmd.CommandType = CommandType.StoredProcedure;
//se ejecuta el SP
if (cnx != null && cnx.State == ConnectionState.Closed)
{
cnx.Open();
dr = cmd.ExecuteReader();
dr.Read();
//se obtiene respuesta si se creo o no el registro en Bitácora
RES = Convert.ToInt32(dr["RES"]);
}
cmd.Connection.Close();
}
catch (Exception ex)
{
String mesg;
int Reg = 0;
mesg = ex.ToString();
RES = 4; //Asigna 4 a Res en caso de algún error durante la operación
//Insertar Registro en Bitácora
String MsgFinal = "Error de Sistema Mensaje de Error: " + mesg;
Reg = CrearBitacora("System", pagWeb, RES, MsgFinal);
//FIN Insertar Registro en Bitácora
}
finally
{
if (cmd != null && cmd.Connection.State != ConnectionState.Closed)
{
cmd.Connection.Close(); //Cerrar conexión de datos
}
else
{
cmd.Connection.Close(); //Cerrar conexión de datos
}
}
return RES;
}
}
Thanks to all.