简体   繁体   English

C#:永远不会达到断点,并且Picturebox Image不会改变

[英]C#: Breakpoint is never reached and Picturebox Image does not change

i was trying to add some kind of advent calender to my programm. 我试图在我的程序中添加某种形式的压延机。
So i created a second form with the designer. 因此,我与设计师创建了第二种表单。
After clicking a toolstripmenuitem following gets executed. 单击工具条菜单后,将执行以下操作。

private void OpenAdventCalender()
{
  if (fAdvent == null)
  {
       fAdvent = new Advent();
       fAdvent.FormClosed += new FormClosedEventHandler(fAdvent_FormClosed);
       AdventOptions[0] = "1";
       fAdvent.Visible = true;
   }
} 

Now that works fine. 现在工作正常。 The Form does open and i can doubleclick picktureboxes. 表单确实打开,我可以双击选择框。
On a doubleclick the image of the picturebox should change. 双击图片框的图像应更改。
I tried it like that: 我这样尝试过:

private void ShowAdventMessage(object sender, EventArgs e)
{
    if(false){}  //in original code i test on 24 days and pictureboxes
    else if ((DateTime.Today >= DateTime.Parse("01.12.2016")) && (sender == pictureBox1))
    {
        fForm1.AdventOptions[1] = "1";
        pictureBox1.Image.Dispose();
        pictureBox1.Image = null;
        pictureBox1.Image = Resources.p1;
        pictureBox1.Update();
        MessageBox.Show(fForm1.AdventList[0]);  //This Message pops up correctly
    }
}  

So the first big Problem is that the pictureBox1 does not change the image. 因此,第一个大问题是pictureBox1不会更改图像。
It also does not get deletet if i set the picturebox to null. 如果我将picturebox设置为null,它也不会被删除。
In the constructor im changing it the first time, there it works. 在第一次更改它的构造函数中,它可以正常工作。 Outside the constructor it does not work. 在构造函数之外,它不起作用。

Now the second problem. 现在第二个问题。 I cannot debug in there. 我不能在那里调试。 Breakpoints in the constructor or in any other function of my second form are never reached. 构造函数或第二种形式的任何其他函数中的断点从未达到。 Since i know that that Messagebox pops up i know it does reach the code. 因为我知道该消息框会弹出,所以我知道它确实可以到达代码。

When i hover over the breakpoint with my mouse, it told me: 当我用鼠标悬停在断点上时,它告诉我:

The breakpoint cannot be reached at the moment. 目前无法到达断点。 The code is differnt to the original version. 该代码与原始版本不同。

It also told me that i can change something in options to reach the breakpoints. 它还告诉我,我可以更改选项以达到断点。
So i changed "Extras - Options - Debugging - General - Sourcefiles must be exactly like the original version = deactivated". 因此,我更改了“其他-选项-调试-常规-源文件必须与原始版本完全相同=已停用”。
After that the breakpoints were still unreachable. 之后,断点仍然无法到达。 Now the message from the breakpoint was: 现在断点发出的消息是:

The breakpoint cannot be reached at the moment. 目前无法到达断点。 There is no executable code with the targetcodetype of the debugger connected with this line. 与该行连接的调试器的目标代码类型没有可执行代码。

Does someone know how to debug in there? 有人知道如何在那里调试吗?
Or does someone know what i am doing wrong so that the image does not change? 还是有人知道我在做什么错,这样图像就不会改变?

What i use if needed: 如果需要,我使用什么:
- Windows 10 professional 64bit -Windows 10专业版64位
- Visual Studio 2015 -Visual Studio 2015
- Resharper Ultimate -Resharper Ultimate

Thanks for any help. 谢谢你的帮助。

After testing if i also cannot debug a complete newly created form, i compiled it fully through project explorer. 经过测试,如果我也无法调试完整的新创建的表单,则可以通过项目资源管理器对其进行完全编译。 After that it worked. 之后,它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM