简体   繁体   中英

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>. 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. However, if one comments out any code that uses saab2ViewModel , it will compile.

Comment out the following:

MainViewModel.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:

In welcomeViewModel.cs , you have:

class welcomeViewModel : MainViewModel
{

}

Change to:

class welcomeViewModel
{

}

and it will run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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