question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InkCanvas.DynamicRenderer set different custom DynamicRenderer multiple times, throw an exception

See original GitHub issue

Description

When using the touch screen, errors will occur, but not when using the mouse

On the touch screen, the two buttons switch and click multiple times to set a custom Dynamic Renderer for InkCanvas.DynamicRenderer. The crash always occurs after DrawPen OnRemoved

Button(DrawPen)、Button(DrawArrow)

`var dr = name switch {
“GeneralPen” => new DrawPen(this),
“ArrowPen” => new DrawArrow(this),
_ => new DrawPen(this), };

DynamicRenderer = dr; `

If set different custom DynamicRenderer multiple times, throw an exception

App_DispatcherUnhandledException--Object reference not set to an instance of an object. at System.Windows.Input.StylusPlugIns.DynamicRenderer.TransitionComplete(StrokeInfo si) at System.Windows.Input.StylusPlugIns.DynamicRenderer.<>c__DisplayClass19_0.<NotifyAppOfDRThreadRenderComplete>b__0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

PC-Test-develop-2.zip

Reproduction Steps

Ditto description

Expected behavior

No exception will be thrown

Actual behavior

Throw thread exception

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

.NET Core Version: .NET 7.0.103 SDK Windows version: Version 22H2 (OS Build 19045.2546)

Other information

No response

Issue Analytics

  • State:open
  • Created 7 months ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
miloushcommented, Feb 15, 2023

Please provide a repro project having the issue.

1reaction
jaelyscommented, Feb 17, 2023

@lindexi Thank you for your help. I updated the Demo and annotated some code that may prevent exceptions. These codes are valid, but not 100%. Now we should be able to simply reproduce the exception. Just press the Pen Button several times, switch another button, and repeat it several times

感謝林德熙大神

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF InkCanvas and DynamicRenderer - Microsoft Q&A
I have a wpf application in which I use an inkcanvas, I generate a video of the strokes in the inkcanvas, using the...
Read more >
InkCanvas Class (System.Windows.Controls)
An InkCanvas is an element that can be used to receive and display ink input. This is commonly done through the use of...
Read more >
Handling same exception thrown by different methods
Is there a pattern that achieves the same result without the need to create custom exceptions when multiple methods throw the same exception?...
Read more >
InkCanvas.cs source code in C# .NET - dotnetframework.org
The length to set /// public static void SetTop(UIElement element, double length) { if (element == null) { throw new ArgumentNullException("element"); } ...
Read more >
Custom Exception that wraps Multiple Exceptions
As your program will throw only one exception at a time then no need to store list of exceptions in NConnectionException .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found