0

i wrote the following code to display a custom Balloon. The Balloon works. It is shown 5 seconds before it disappears. But then it throws an Exceptioon which i can't catch... and i dont unterstand why it is thrown.

String title = "Trelp Balloon Info";
String text = "Trelp started";

try
{
     tbi.ShowCustomBalloon(MakeCustomBalloonStackPanel(title, text), System.Windows.Controls.Primitives.PopupAnimation.Slide, 5000);
}
catch (Exception e) {
     Console.WriteLine(e.ToString());
}

The Balloon is shown with my correct Content. But even the 'normal' ShowBalloonTip throws the same exception. The docs of the 'normal' ShowBalloonTip says that this Exception will be thrown when the timeout is lower then 0 or negative... but it isn't here.

I am using this Library to make the custom Balloon: http://www.codeproject.com/Articles/36468/WPF-NotifyIcon

Hope you have any suggestions for me :-) thanks

EDIT:

when i put the whole thing into an Thread and kill that thread after 4999 ms (timeout of balloon is 5000) the exception isn't thrown. BUT thats not a real solution.

Laokoon
  • 1,241
  • 4
  • 24
  • 47
  • The call to ShowCustomBalloon probably finishes instantly, since we're talking about UI code here. The object returned by MakeCustomBalloonStackPanel is probably throwing the exception, and would be happening in a call stack that you aren't causing - probably the UI code firing a timer that the shown object is responding to and then breaking. – antiduh Jul 03 '13 at 19:11
  • Ok thanks, sounds logical. What do you think I can do about that? It also happens on the standard Balloon with just a text and no custom UI Elements. – Laokoon Jul 03 '13 at 19:24
  • Well, there's not a lot of context to go off of - where is MakeCustomBalloonStackPanel - your code, or in WPF-NotifyIcon's code? Do you have access to the source code for MCBSP and the object it returns? If so, I'd go trundling through there and see if you can find any code that responds to a form/window/pane close, or perhaps look for the close timer. Something in there is what's breaking. You should be able to tell Visual Studio to break on any exception, cause it, and then look at the stack trace to find out what broke and where that code is. – antiduh Jul 03 '13 at 19:27
  • Visual Studio shows me String.cs with the Exception-Popup with no StackTrace,no Code, no Code line. Exception Snapshot: {Source: mscorlib,, StrackTrace: at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)} ... – Laokoon Jul 03 '13 at 19:38
  • 1
    You're going to need a full stack trace. The population should have a link button to show it. If not, before running your program, go to the debug menu, exceptions, and check the box to have it catch all exceptions. That'll cause the debugger to break on any and all exceptions, allowing you to see exactly what broke – antiduh Jul 03 '13 at 19:58

0 Answers0