This project is read-only.

InvalidOperationException when graph has no vertices and edges

Feb 11, 2013 at 9:10 PM
Edited Feb 11, 2013 at 9:24 PM
Hello. I don't undestand, why this example throw exception. I start example which on tutorial at this site named "Pretty Cool Graphs In WPF ". It works, but when I try to start this example in WinForms application in the UserControl when graph is empty I get exception InvalidOperationException. Roughly, source example and my code differs only in XAML - UserControl tag instead WindowTag. Also my constuct of MainWindowViewModel consists only initialization of graph:
Graph = new PocGraph(false);

Exception:
Source - System.Core
StackTrace - " в System.Linq.Enumerable.First[TSource](IEnumerable1 source)\r\n в GraphSharp.Algorithms.Layout.Simple.Tree.SimpleTreeLayoutAlgorithm3.GenerateSpanningTree()\r\n в GraphSharp.Algorithms.Layout.Simple.Tree.SimpleTreeLayoutAlgorithm3.InternalCompute()\r\n в GraphSharp.Algorithms.AlgorithmBase.Compute()\r\n в GraphSharp.Controls.GraphLayout3.Layout(Boolean continueLayout)\r\n в GraphSharp.Controls.GraphLayout`3.<>c__DisplayClass1f.<Layout>b__e(Object s, RoutedEventArgs e)\r\n в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n в System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n в System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)\r\n в System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)\r\n в System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)\r\n в MS.Internal.LoadedOrUnloadedOperation.DoWork()\r\n в System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()\r\n в System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()\r\n в System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)\r\n в System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)\r\n в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)\r\n в System.Windows.Threading.DispatcherOperation.InvokeImpl()\r\n в System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)\r\n в System.Threading.ExecutionContext.runTryCode(Object userData)\r\n в System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)\r\n в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)\r\n в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n в System.Windows.Threading.DispatcherOperation.Invoke()\r\n в System.Windows.Threading.Dispatcher.ProcessQueue()\r\n в System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n в MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)\r\n в System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)\r\n в MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n в System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n в System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n в System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n в System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n в System.Windows.Forms.Application.Run(Form mainForm)\r\n в Preducational.Program.Main() в E:\!diplom\Preducational\Preducational\Program.cs:строка 20" string


Please, help me make it work. Sorry for my poor english