简体   繁体   English

如何防止在我运行 WPF MVVM 应用程序时引发“System.StackOverFlowException”异常?

[英]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.

相关问题 System.StackOverflowException WPF MVVM - System.StackOverflowException WPF MVVM 引发了类型为&#39;System.StackOverflowException&#39;的异常。 - Exception of type 'System.StackOverflowException' was thrown.' 抛出了类型&#39;System.StackOverflowException&#39;的异常 - Exception of type 'System.StackOverflowException' was thrown 启动应用程序时出现 System.StackOverflowException - System.StackOverflowException when launching application 错误:get属性中引发了类型为&#39;System.StackOverflowException&#39;的异常 - Error: Exception of type 'System.StackOverflowException' was thrown in get property WorldServer类引发了类型为System.StackOverflowException的异常 - Exception of type 'System.StackOverflowException' was thrown by WorldServer class C#中引发了类型为&#39;System.StackOverflowException&#39;的异常 - Exception of type 'System.StackOverflowException' was thrown in c# 在启动我的MVC3应用程序时,在mscorlib.dll中出现“类型&#39;System.StackOverflowException&#39;的未处理异常”? - On starting my MVC3 application, getting “An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll”? my.dll中发生了System.StackOverflowException类型的未处理异常? - An unhandled exception of type System.StackOverflowException occurred in my.dll? 递归调用方法时,防止System.StackOverflowException - Prevent System.StackOverflowException when recursively calling a method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM