C# WPF error reporting


I usually debug by sending messages to the console via RhinoApp.WriteLine but I’ve recently encountered a very stubborn bug that I would like to collect more information about. The application is a WPF plugin for Rhino.

I have tried using other error and exception reporting processes (without luck) such as:

Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

Can anyone please advise a best practice for catching errors before a WPF rhino plugin/application crashes?

Sincere thanks.


if you are in Visual Studio, you can set breakpoints. In order to step through, You’ll need to attach to the Rhino Process, once you started it. This is actually the only way to debug seriously :slight_smile:
Furthermore, it might be useful to separate the Gui logic from the Model logic (Geometric computation). This potentially mean you can test the Gui with a mocked functionality as a stand alone app. And last but not least, writing Unit tests is helpful. A Unit test may not require you to start Rhino, depending if you need to use Rhinocommom or not…

1 Like


Thanks for this. I use breakpoints in other IDEs for stand alone applications and never bothered to learn how to use them for plugin development but this is useful and I’ve got it working. The plugin was written modularly with separate logic.

While I have your ear. Can I ask have you ever written a WPF? I’ve spent two days chasing this particular bug. It involves updating a slider maximum value. I’m not sure if I just don’t understand this particular binding or if I’m not understanding something else, either how events work in this particular instance or if I’m doing something wrong with a background worker. I can submit a new question to the list if you think it’s relevant here.

Actually I do earn my money with WPF development at the moment.

Generally spoken, WPF has a steep learning curve. The best is you post another thread here or on Stack overflow. You can set the mode of the binding indicating which direction the Binding is active. If the user is triggering a change on the Gui you need to set the binding mode to TwoWay or OneWayToSource. If the logic is triggering a change and should affect you‘ll need to set to OneWay or Twoway or OneTime mode.
If the Maximum is a self written property
you also need to make sure if the NotifyPropertyChanged-Event gets fired once to notify the user control to fetch the actual data from it and to do a local rerender.
Without code its almost impossible to help. Just start a new thread providing some code.
Bytheway, Xaml debugging is another deal. As I said a good idea is to seperate the Gui from the Model by using a MVVM pattern. In theory this would allow you to debug the view logic much easier, and might also allow you to thread the GUI for testing purpose as a standalone app.