Tengo una aplicación WinForms donde estoy arrastrando y soltando entre 2 TreeViews.Excepción tragada al arrastrar y soltar
En algún momento, quiero rechazar la acción en la implementación empresarial subyacente, por lo que lanzo una excepción. Puedo ver la excepción en la ventana de salida, pero el problema es que no puedo verlo en la interfaz de usuario y no se cuelga.
¿Adónde fue la Excepción?
Aquí hay un código que describe el problema:
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());
}
}
Probablemente querrá compartir un código para este – AlexCuse