KeyNotFoundException in DefaultAppearanceProvider.TryGetCurrentAnnotationAppearances when loading PDF with FreeText/Widget annotation containing invalid "/AP << /N 0 0 R >>" reference (likely macOS Preview-authored)
Loading a PDF containing an annotation with a broken appearance reference (/AP << /N 0 0 R >> — an indirect reference to object 0, which is reserved/invalid per the PDF spec) throws an unhandled KeyNotFoundException deep inside the rendering pipeline when the affected page is scrolled into view. This crashes the hosting WPF application, since the exception originates inside WPF's layout/render callback (OnRender) rather than during the initial PdfFormatProvider.Import() call, so it cannot be caught by application-level try/catch around import.
I found this appears to match a previously reported and fixed issue: "PdfViewer: KeyNotFoundException is thrown when loading a document with Free Text Annotation," fixed in Release 2024.3.924. I'd like confirmation this is the same root cause and whether 2024.3.924+ resolves it, or if this is a distinct case given the specific /N 0 0 R malformation I've isolated.
RadPdfViewer via PdfFormatProvider.Import() with ImportSettings = PdfImportSettings.ReadOnDemand.RadFixedDocument to RadPdfViewer.Document.System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.Windows.Documents.Fixed.Model.Annotations.MultiStateAppearances.get_Item(String stateName)
at Telerik.Windows.Documents.Fixed.Utilities.Rendering.Annotations.DefaultAppearanceProvider.TryGetCurrentAnnotationAppearances(Annotation annotation, SingleStateAppearances& singleStateAppearances)
at Telerik.Windows.Documents.Fixed.Utilities.Rendering.Annotations.DefaultAppearanceProvider.TryProvideAppearanceOverride(Annotation annotation, AnnotationAppearanceMode annotationAppearanceMode, FormSource& formSource)
at Telerik.Windows.Documents.Fixed.Utilities.Rendering.Annotations.BaseAppearanceProvider.TryProvideAppearance(Annotation annotation, AnnotationAppearanceMode annotationAppearanceMode, FormSource& appearance)
at Telerik.Windows.Documents.Fixed.Utilities.Rendering.Annotations.BaseAppearanceProvider.TryProvideAppearance(Annotation annotation, AnnotationAppearanceMode annotationAppearanceMode, FormSource& appearance)
at Telerik.Windows.Documents.Fixed.Utilities.Rendering.FixedPageContentRenderingHelper.RenderNormalAnnotationAppearance(IFixedContentRenderer renderer, Annotation annotation)
at Telerik.Windows.Documents.Fixed.UI.AnnotationAppearancesCanvas.DrawAppearance(DrawingContext drawingContext)
at Telerik.Windows.Documents.Fixed.UI.AnnotationAppearancesCanvas.OnRender(DrawingContext dc)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Canvas.ArrangeOverride(Size arrangeSize)
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.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)The offending annotation object in the PDF:
181 0 obj
<< /AP << /N 0 0 R >>
/M (D:20231128120931Z00'00')
/Rect [ 67.664 412.788 527.774 446.2222 ]
/AAPL:SFF true
/F 4
/DA (//Menlo-Regular 14 Tf 0 g)
/AAPL:AKExtras
<< /AAPL:AKPDFAnnotationDictionary
<< /AP << /N 0 0 R >>
.../AP << /N 0 0 R >> is an indirect reference to object number 0, which is reserved by the PDF spec (head of the free-object list) and never resolves to a real object./AAPL:SFF, /AAPL:AKExtras, /AAPL:AKPDFAnnotationDictionary keys indicate this annotation was written by macOS Preview.app (Apple's proprietary annotation/markup extensions), consistent with a document that was signed or markup-annotated on a Mac before being distributed.DefaultAppearanceProvider.TryGetCurrentAnnotationAppearances does: singleStateAppearances = appearances[appearances.CurrentState];with no existence/null check before indexing — when CurrentState doesn't resolve to a valid key (because the backing /N reference was never a valid object), this throws KeyNotFoundException uncaught.
This exception occurs during WPF's internal render callback, outside the call stack of the code that calls PdfFormatProvider.Import(), so it cannot be caught by a standard try/catch around import/load. It surfaces as a DispatcherUnhandledException on the UI thread and, without an application-level workaround, crashes the hosting application entirely.
/N 0 0 R invalid-reference pattern?/N 0 0 R malformation, not just the FreeText-annotation case?Appearances/MultiStateAppearances members, which is fragile across versions.)TryGetCurrentAnnotationAppearances already has "Try" in its name implying safe failure, could this be hardened with a TryGetValue instead of the indexer, to fail gracefully rather than throw, for any similarly malformed future document?1. Create clean WinForms .NET Framework project.
2. Add Telerik UI for WinForms 2026.2.520.462.
3. Create BaseForm : RadForm.
4. Add RadStatusStrip to BaseForm.
5. Create inherited form RadForm1 : BaseForm.
6. Open inherited form in Visual Studio designer.
7. Designer crashes with NullReferenceException in Telerik.WinControls.UI.Design.RadControlDesigner.OnSetCursor.
8. Remove/comment RadStatusStrip from BaseForm.Designer.cs.
9. Designer opens successfully.
Sample project attached.
Hi, I would like to use the conversion tool to convert a WinForms project to Telerik controls. Unfortunately the menu item is not showing up for me. See attached screenshot.
The project to be converted does include a reference to System.Windows.Forms. I am using VS2019 with the latest Telerik Winforms release.
Thanks,
-Lou
In this particular scenario, we have 2 monitors. One with 100 % and one with 150% DPI. When the ScreenTip is shown in 100%, its size is correct. Then if we move the Form to the second monitor that is 150%, the screenTip size is not scaled when shown for the first time. We need to move the mouse to hide and show it again. The second time, the size is correct.
Clients with perpetual license may observe the following warning when using UI.for.WinForms.AllControls.Net90 (v.2026.1.415):
Telerik and Kendo UI Licensing warning TKL403: Services associated with Telerik Document Processing Libraries version 2026.1.402.80 require a subscription or trial license. Please obtain a subscription license at https://prgress.co/3PwQMKZ
Telerik and Kendo UI Licensing warning TKL004: Unable to locate licenses for all products.
Hi support,
I think I found an issue with the default behavior of Telerik UI for Winforms on a HighDPI PerMonitorV2 configuration.
The application works correctly and resizes well if moved between screen with different Font Scalings.
However, if the user changes the main screen to one with a different scaling, the application is strangely taking the change into account and would also not come back to its original state.
Attached is a GIF showing the problem and the project. The application on run on screen 3 being main display at 100% FontScale. If I pass Screen 1, the main display (which is 125% font scaled), the icons of the app are made larger (for no reason), going back to screen 1 being the main screen, will not restore the icon to the correct size, unless you make parts of the application being redrawn.
I've a more related question but it's more complex and I won't be able to provide a project for this, so I'm just trying here ;) In our real application (not this test one), when setting PerMonitorV2 mode, we need to have RadControl.EnableRadAutoScale set to false for the controls to resize correctly when changing monitors whereas this [test] application needs it to be let it set to true to kind of do the same thing ?! Any idea on where the difference can come from ?
Thanks & regards,
Benjamin Foucher
Repro-steps:
Expected behavior:
Observed behavior:
I traced the problem back to the method GridViewSleectedCellsCollection.IsSelected / GetHashCodeString.
internal bool IsSelected(GridViewRowInfo row, GridViewColumn column) => row != null && column is GridViewDataColumn && this.hashtable.Contains((object) this.GetHashCodeString(row, column));When a cell is selected with GridViewCellInfo.IsSelected = true, it checks if it has already been selected. It does so by calling GridViewSleectedCellsCollection.IsSelected. which checks if a HasCodeString is already in a hashtable. But, when another selected cell has the same HasCodeString, the result is (incorrectly) true, which will result in not added it to the collection of selected cells.
I guess that is can be easily fixed by changing:
private string GetHashCodeString(GridViewRowInfo row, GridViewColumn column)
{
int hashCode = row.GetHashCode();
string str1 = hashCode.ToString();
hashCode = column.GetHashCode();
string str2 = hashCode.ToString();
return str1 + str2;
}to:
private string GetHashCodeString(GridViewRowInfo row, GridViewColumn column)
{
int hashCode = row.GetHashCode();
string str1 = hashCode.ToString();
hashCode = column.GetHashCode();
string str2 = hashCode.ToString();
return str1 + "_" + str2;
}Since hashcodes 1 + 23 will result in the same string as hashcodes 12 + 3.
Making this change will reduce the problem significantly, but not entirely since hashCodes will never be unique.
In the Visual Theme Builder (fresh installed Telerik UI for WinForms) you'll get an error because the directory "VbsRecoveryData" seems to be missing. Creating the directory before "package.Compress(path)" fixes this for me.
The content is exported correctly, but the following error occurs:
I am working with the RadListView and noticed that its right and bottom border gets clipped at some (not all) width/heights and some scale factors (most notably 150% and 175%). This problem does not occur with the basic System.Windows.Forms.ListView.
Here is the code that I have wrote to replicate this problem with both the WinForms list view and the RadListView.
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.radListView1 = new Telerik.WinControls.UI.RadListView();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.SuspendLayout();
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(155, 10);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(135, 175);
this.radListView1.Location = new System.Drawing.Point(5, 10);
this.radListView1.Name = "radListView1";
this.radListView1.Size = new System.Drawing.Size(135, 175);
this.radListView1.UseCompatibleTextRendering = true;
this.Controls.Add(this.radListView1);
this.Controls.Add(this.listView1);
this.Name = "RadForm1";
this.Text = "RadForm1";
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout(false);
}Here is a screenshot of the dialog when the scale factor is at 100% (left is the RadListView component):
and here is a screenshot of when my display is scaled at 150% (left is the RadListView component):
To replicate: run the project attached, both at 100% scaling and 150% scaling.
Thanks!
There is a big problem with Telerik controls when using national resource files. Switching from one language to another and again sometimes destroys the user interface. It especially concerns RadCheckBox control. Text, tooltip and probably other properties from one control appear in other control etc. I think it can be a general problem because I also noticed that sometimes Image from one RadButton control appears in other button.
I prepared a set of images which show how it happended in my case. Switching from Default language to Polish language and again and then adding and removing new RadCheckBox completly destroyed user interface in my sample UserControl. This new RadCheckbox was created as a copy of existing RadCheckBox what may be a clue.
I also attached VS2019 project with my sample UserControl.
Best regards,
Andrzej