Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 信息已输出到控制台(如果存在)并写入事件日志。OP已经得到了坠机信息;他们担心的是它缺少调试信息(作为一个优化的构建)。我看不出上述方法对诊断问题有什么帮助,不要介意为OP实际解决问题。这是一个很长的说法:这不是这个问题的答案。我尝试包装我的程序,但得到的_C#_.net_C# 4.0_Console Application - Fatal编程技术网

C# 信息已输出到控制台(如果存在)并写入事件日志。OP已经得到了坠机信息;他们担心的是它缺少调试信息(作为一个优化的构建)。我看不出上述方法对诊断问题有什么帮助,不要介意为OP实际解决问题。这是一个很长的说法:这不是这个问题的答案。我尝试包装我的程序,但得到的

C# 信息已输出到控制台(如果存在)并写入事件日志。OP已经得到了坠机信息;他们担心的是它缺少调试信息(作为一个优化的构建)。我看不出上述方法对诊断问题有什么帮助,不要介意为OP实际解决问题。这是一个很长的说法:这不是这个问题的答案。我尝试包装我的程序,但得到的,c#,.net,c#-4.0,console-application,C#,.net,C# 4.0,Console Application,信息已输出到控制台(如果存在)并写入事件日志。OP已经得到了坠机信息;他们担心的是它缺少调试信息(作为一个优化的构建)。我看不出上述方法对诊断问题有什么帮助,不要介意为OP实际解决问题。这是一个很长的说法:这不是这个问题的答案。我尝试包装我的程序,但得到的消息并没有告诉我很多我已经知道的内容:3/12/2015 11:21:59 AM/t System.NullReferenceException:对象引用未设置为对象的实例。在BWC2Mailer.Program.Main(String[]ar


信息已输出到控制台(如果存在)并写入事件日志。OP已经得到了坠机信息;他们担心的是它缺少调试信息(作为一个优化的构建)。我看不出上述方法对诊断问题有什么帮助,不要介意为OP实际解决问题。这是一个很长的说法:这不是这个问题的答案。我尝试包装我的程序,但得到的消息并没有告诉我很多我已经知道的内容:3/12/2015 11:21:59 AM/t System.NullReferenceException:对象引用未设置为对象的实例。在BWC2Mailer.Program.Main(String[]args)3/12/2015 11:21:59 AM/t在BWC2Mailer.Program.Main(String[]args)@Jason,您的部署程序中肯定有
.pdb
文件?@user1我不是通过安装来卸载它的,我是从debug bin文件夹中获取可执行文件的。我应该仍然能够以这种方式正确运行它,对吗?是的,所以当您将程序从调试中取出时,也要将所有的.pdb文件都带上。。这将提供有关您的异常的更多信息(行号等)
namespace BWC2Mailer
{
    class Program
    {
       static void Main(string[] args)
        {


            String constr = ConfigurationManager.ConnectionStrings["binddropdown3"].ConnectionString;

            SqlConnection con = new SqlConnection(constr);
            con.Open();          

                SqlCommand cmd1 = new SqlCommand("SELECT distinct TestEmail, TestBWC FROM TestTable2 WHERE CONVERT(CHAR(10), GETDATE(), 101) = DATEADD(day,-2, TestBWC) AND TestBWC <> '' AND TestEmail <> ''", con); // Test
                SqlDataReader rd1 = cmd1.ExecuteReader();

                if (rd1.HasRows)
                    {
                SqlConnection con3 = new SqlConnection(constr);

                while (rd1.Read())
                {

                  var EmailToSendPre = rd1["TestEmail"].ToString(); // Test Email


                    string EmailToSend = EmailToSendPre.Replace("`", "");

                  string ExpirationDate = rd1["TestBWC"].ToString();


                    if (emailIsValid(EmailToSend))
                    {


                        var TodayIs = DateTime.Today.ToString("MM/dd/yyyy");

                        con3.Open();

                        var QType = "BWC2";
                        var BWCSubject = "5th Notice-2 days prior";

                        string BWCBody = "<p>...</p>";

                        SqlCommand cmd3 = new SqlCommand("SELECT * From EmailNotificationStatus WHERE Email = '" + EmailToSend + "' AND SendDate = '" + TodayIs + "' AND QueryType ='" + QType + "'", con3);
                        SqlDataReader rd3 = cmd3.ExecuteReader();

                        if (!rd3.Read())
                        {

                            MailMessage mailObj = new MailMessage(
                                "noreply@xxxx.com", EmailToSend, BWCSubject, BWCBody);
                            SmtpClient SMTPServer = new SmtpClient("xxxx.xxxxx.com"); // 

                            MailAddress cc = new MailAddress("xxxx@xxxx.com");
                            mailObj.CC.Add(cc);

                            mailObj.IsBodyHtml = true;
                            try
                            {
                                SMTPServer.Send(mailObj);
                            }

                            catch (Exception ex)
                            {


                            }
                            var TodayNow = DateTime.Today.ToString("MM/dd/yyyy");


                            SqlConnection con2 = new SqlConnection(constr);

                            con2.Open();



                            SqlCommand cmd2 = new SqlCommand("Insert INTO EmailNotificationStatus(Email,Sent,QueryType,SendDate) values(@email,@Sent,@QueryType,@SendDate)", con2);
                            cmd2.Parameters.Add("@email", SqlDbType.VarChar).Value = EmailToSend;
                            cmd2.Parameters.Add("@Sent", SqlDbType.VarChar).Value = "YES";
                            cmd2.Parameters.Add("@QueryType", SqlDbType.VarChar).Value = "BWC2";
                            cmd2.Parameters.Add("@SendDate", SqlDbType.VarChar).Value = TodayNow;

                            cmd2.ExecuteNonQuery();

                            con2.Close();


                        }
                    }



                    con3.Close();
                }
            }

            }



public static bool emailIsValid(string email)
    {
        string expresion;
        expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
        if (Regex.IsMatch(email, expresion))
        {
            if (Regex.Replace(email, expresion, string.Empty).Length == 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
try
{

}
catch (exception ex)
{
     using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@".\error.log",true))
     {
         sw.Write(String.Format("{0}/t {1}", DateTime.Now, ex.ToString()));
         sw.Write(String.Format("{0}/t {1}", DateTime.Now, ex.StackTrace.ToString()));
     }
}