[英]How to prevent the "System.StackOverFlowException" exception being thrown when i run my WPF MVVM application?
I tried to add a feature to my app where it saves the value from a textbox after a button is clicked.我试图向我的应用程序添加一个功能,它在单击按钮后保存文本框中的值。 It threw the exception said above and i cant find why it did.
它抛出了上面所说的异常,我找不到它的原因。 Here is the link to the project <github.com/lovelygentleman/TacticalSimInstaller>.
这是项目的链接 <github.com/lovelygentleman/TacticalSimInstaller>。 Would someone mind taking a look through it and find out whats wrong?
有人介意看看它并找出问题所在吗?
The code doesn't initially compile because saab2ViewModel
seems to be missing.该代码最初没有编译,因为
saab2ViewModel
似乎丢失了。 However, if one comments out any code that uses saab2ViewModel
, it will compile.但是,如果注释掉任何使用
saab2ViewModel
的代码,它将编译。
Comment out the following:注释掉以下内容:
MainViewModel.cs主视图模型.cs
...
//public saab2ViewModel Saab2VM { get; set; }
...
//Saab2VM = new saab2ViewModel();
...
//Saab2ViewCommand = new RelayCommand(o =>
//{
// CurrentView = Saab2VM;
//});
...
After it compiles, upon execution, one receives the following error An unhandled exception of type 'System.StackOverflowException' occurred...
which can be fixed by making the following modification:编译后,在执行时,会收到以下错误
An unhandled exception of type 'System.StackOverflowException' occurred...
可以通过进行以下修改来修复:
In welcomeViewModel.cs , you have:在welcomeViewModel.cs中,您有:
class welcomeViewModel : MainViewModel
{
}
Change to:改成:
class welcomeViewModel
{
}
and it will run.它会运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.