Stack Trace in GoXAM on link click

I’m using GoXAM for WPF 1.3.5.4 and whenever I click on a specific GraphLinksModelLinkData link in my code I get the below unhelpful stack trace and my app crashes. I’d appreciate any pointers/help!

  • Update: I just found out that removing this: LinkReshapeHandleTemplate=“LinkReshapeHandleTemplate” stops it from crashing, so that’s what I’m doing now.

Here is the rendering template, which is mostly copied & pasted from a GoXAM example:

And here is the construction of the link:
new GraphLinksModelLinkData<string, string>(atomView.Key, null) { Text = inputDef.LinkName, Category=“defaultLinkTemplate” }

And here is the exception:

System.InvalidCastException was unhandled
Message=Unable to cast object of type ‘System.String’ to type ‘System.Windows.DataTemplate’.
Source=Northwoods.GoWPF
StackTrace:
at Northwoods.GoXam.Route.get_LinkReshapeHandleTemplate()
at Northwoods.GoXam.Link.get_LinkReshapeHandleTemplate()
at Northwoods.GoXam.Tool.LinkReshapingTool.UpdateAdornments(Part part)
at Northwoods.GoXam.Part.UpdateToolAdornments()
at Northwoods.GoXam.Part.UpdateAdornments()
at Northwoods.GoXam.Part.#Gj(DiagramPanel #z4)
at Northwoods.GoXam.DiagramPanel.#0q(HashSet1 #M8, HashSet1 #N8)
at Northwoods.GoXam.DiagramPanel.#0q()
at Northwoods.GoXam.DiagramPanel.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at Bae.RuleTool.View.App.Main() in C:\X\FASTER2\Code\FASTER2\DOTNET\RuleTool\View\obj\x86\Debug32\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

That link data’s Category doesn’t match the name of the Link DataTemplate, but that’s not the reason for the exception. However it does make me wonder if you posted the correct Link DataTemplate, because it does not set the Link.LinkReshapeHandleTemplate property. Do you have multiple DataTemplates for Links?

In fact, the more I think about it, the less sense it makes. Are you sure that what you are running includes assemblies only compiled with the same Northwoods.GoWPF.dll?

Sorry about that, I just noticed that I copied & pasted the wrong link template. I updated the post. Removing the reference to this reshape handle template fixed it:

<go:ToolHandle go:NodePanel.Figure=“Diamond” Width=“7” Height=“7” Fill=“LightBlue” Stroke=“DeepSkyBlue” StrokeThickness=“1” />

Ah, yes, that’s the problem – the value of LinkReshapeHandleTemplate needs to be a DataTemplate, not a string. Something like:
LinkReshapeHandleTemplate="{StaticResource MyLinkHandle}"

Thank you!!!

I’m still getting used to this XAML everything is a String and some things are compile-time checked and some things aren’t business.