debugging C#断点命中调试器

wb1gzix0  于 2022-11-14  发布在  C#
关注(0)|答案(1)|浏览(239)

我刚刚用C#完成了我的第一个项目之一,但随后我遇到了以下问题:
实时事件:断点命中:Timer1_tick,Forn调试器命中断点或跟踪点
我找不到我的代码有什么问题,所以我真的不知道如何解决这个问题。下面是我一直在尝试的代码:

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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            webBrowser1.Navigate("mywebsite.com");
            webBrowser1.ScriptErrorsSuppressed = true;
        }
        private int failed = 0;
        string startbet = "250";
        string bet2 = "150000";
        string bet3 = "300000";
        string bet4 = "600000";
        string bet5 = "1200000";
        string bet6 = "2400000";
        string bet7 = "4800000";
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("brukernavn")[0].SetAttribute("value", textBox1.Text);
            webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("passord")[0].SetAttribute("value", textBox2.Text);
            webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("login_buton")[0].InvokeMember("click");
            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            webBrowser1.Navigate("mywebsite.com/gamblingsite.php");
            webBrowser1.DocumentCompleted += Krigside;
            timer1.Enabled = false;
        }
        private void Krigside(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            webBrowser1.DocumentCompleted -= Krigside;
            timer2.Enabled = true;
            timer2.Interval = 1000;
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (webBrowser1.DocumentText.Contains("bokstavene"))
            {
                MessageBox.Show("Anti-bot! du har 60 sekunder på og fullføre!");
                timer2.Enabled = true;
                timer2.Interval = 60000; //60 sekunder før den sjekker anti-bot igjen.
            }
            else
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", startbet);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer2.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
        }
        private void SjekkVinnFeil(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            MessageBox.Show("KRIG SIDEN ER KLAR!");
            webBrowser1.DocumentCompleted -= SjekkVinnFeil;
            if (webBrowser1.DocumentText.Contains("taper"))
            {
                failed += 1;
            }
            else
            {
                failed = 0;
            }
            timer3.Enabled = true;
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            if (webBrowser1.DocumentText.Contains("bokstavene"))
            {
                MessageBox.Show("Anti-bot! du har 60 sekunder på og fullføre!");
                timer3.Enabled = true;
                timer3.Interval = 60000; //60 sekunder før den sjekker anti-bot igjen.
            }
            else if (failed == 3)
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", bet2);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
            else if (failed == 4)
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", bet3);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
            else if (failed == 5)
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", bet4);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
            else if (failed == 6)
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", bet5);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
            else if (failed == 7)
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", bet6);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
            else if (failed == 8)
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", bet7);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
            else
            {
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", startbet);
                webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
                timer3.Enabled = false;
                webBrowser1.DocumentCompleted += SjekkVinnFeil;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            timer2.Enabled = false;
            timer3.Enabled = false;
            MessageBox.Show("Stoppet!");
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

而且我已经检查了我的代码几次了,但不明白哪里出了问题。我对C#还是个新手。接下来我可以尝试什么呢?

gt0wga4j

gt0wga4j1#

那么你唯一的问题是为什么断点会命中?如果是,那么这是因为你在某个时候为了调试的目的设置了断点。如果你不想再使用它们,那么你可以考虑通过选择debug菜单选项并选择delete all breakpointdisable all breakpoint来删除断点。
您也可以考虑使用start without dedbugging选项在Release模式下运行应用程序。(或)在web.config/app.config中设置下面的行

<Compilation debug="false" />

相关问题