简体   繁体   English

XNA - 进程在调试时意外终止

[英]XNA - Process terminates unexpectedly while debugging

I have a curious problem with debugging my XNA project. 调试我的XNA项目时遇到了一个奇怪的问题。 Whenever I hit a certain breakpoint and start browsing the "Locals" window, the whole process and the debugger terminate without giving any notice as to why. 每当我点击某个断点并开始浏览“Locals”窗口时,整个过程和调试器都会终止,而不会通知原因。 The trigger might be reaching a field with a red exclamation mark that says "Function evaluation was aborted." 触发器可能到达带有红色感叹号的字段,该感叹号显示“功能评估已中止”。

I am using no explicit multithreading in my code, therefore I am befuddled how the process can terminate (seemingly as though it correctly reached the end) when it actually doesn't run. 我在我的代码中没有使用显式多线程,因此我很困惑,当它实际上没有运行时,进程如何终止(看似好像它正确到达终点)。

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

This is occurring because your accessor is infinitely recursive, causing a stack overflow. 这是因为您的访问器是无限递归的,导致堆栈溢出。

Change this: 改变这个:

get { return Level; }

To this: 对此:

get { return level; }

This is actually a fairly common thing in Visual Studio C#, it's very annoying, the auto-complete feature will always prefer the accessor name over the member name, even when you're within the accessor itself. 这实际上是Visual Studio C#中相当常见的事情,它非常烦人,自动完成功能总是更喜欢成员名称上的访问者名称,即使您在访问者本身内也是如此。 I figured after 5 years of this Microsoft would've fixed it by now. 我认为,经过5年的努力,微软现在已经修复了它。

EDIT: n/m I see you already came to this conclusion in your own question. 编辑:不,我看到你已经在自己的问题中得出了这个结论。 I guess I should read the entire thing first, I jumped the gun. 我想我应该首先阅读整个事情,我跳了枪。

Ok, I have found the solution, so, for anyone who might happen upon this question with a similar problem: The debugger hangs when trying to evaluate a property that causes a stack overflow, ie 好的,我找到了解决方案,因此,对于可能在这个问题上遇到类似问题的任何人:调试器在尝试评估导致堆栈溢出的属性时挂起,即

protected int level;
    public int Level
    {
        get { return Level; }
    }

as is further explained here http://netpl.blogspot.com/2009_05_01_archive.html 正如此处进一步解释的那样http://netpl.blogspot.com/2009_05_01_archive.html

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

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