Reputation: 1105
Just got a very mysterious error while coding a WPF-application in C#.
I've got an event in a custom User-Control, that shows a message box every time the text on a button is changed. When I edit the text on the button in XAML, the event fires - even without my application actually running.
When I tried to open a new WPF-window in the event, the app crashes with "Stackoverflow" - after that, VS (C# Express) crashed too and I wasn't able to open my project until I changed the event and deleted all content in my Debug and Release folders.
Why is this event triggered?
Upvotes: 1
Views: 415
Reputation: 6653
Some code can still run InDesignMode
is your xaml bound to a DataProvider?
Upvotes: 0
Reputation: 391276
A usercontrol runs inside Visual Studio.
Basically Visual Studio loads the assembly containing the control and executes the control.
This means that if your control shows a message box for some event that is executed at design time, then that message box will be shown in Visual Studio as well.
To fix this, make sure your control doesn't execute harmful or similar code when hosted in Visual Studio.
Upvotes: 4