I have a WinForms application where I'm doing drag and drop between 2 TreeViews.
At some point, I want to reject the action in the underlying business implementation, so I throw an Exception. I can see the Exception in the Output window but the problem is that I can't see it in the UI and it doesn't crashes.
Where did the Exception go?
Here is some code that describes the problem:
private TreeView tvLeft;
private TreeView tvRight;
private Dictionary<string, int> dico = new Dictionary<string, int>();
void tvLeft_DragDrop(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(typeof(TreeNode))) {
var tnSource = (TreeNode) e.Data.GetData(typeof(TreeNode));
var tnDestination = tvLeft.GetNodeAt(tvLeft.PointToClient(new Point(e.X, e.Y)));
// if I drag-drop the same node twice, there sould be an Exception
// since the key is already in the dictionary...
// ...but I get no Exception in the UI, the Application.ThreadException
// or Appomain.CurrentDomain.UnhandledException handlers
dico.Add(tnSource.Name, (new Random()).Next());
}
}