Open jeffz29 opened 10 months ago
PDF file still to follow.
Having the same problem... any news?
Having the same problem... any news?
Still waiting for the PDF file.
Hi,
I am having the same issue.
Dot net Framework 4.8 does not support modifying dictionary entries while being enumerated. This can be reproduced by running the following:
[Fact]
public void Test()
{
var dict = new Dictionary<string, string>
{
{"1", "1"},
{"2", "2"}
};
foreach (var element in dict)
{
dict[element.Key] = "3";
}
}
This will fail on 4.8 but will work on net 6.
A quick fix is to just do a .Tolist:
foreach (var element in dictionary.Elements.ToList())
I hope that helps
Any PDF with content would probably cause the error (works fine in net6 but fails in net48) but here's an example:
We fixed this issue at two code locations with 6.1.0 Preview 2 (coming sooner or later). We check for other affected code spots.
Great... When do you think 6.1.0 Preview 2 will be available on nuget? 🤞
Great... When do you think 6.1.0 Preview 2 will be available on nuget? 🤞
Sooner or later. No ETA set yet.
After updating to 6.1.0-preview-1, I am unable to open a pdf for modification.
When calling PdfReader.Open(path, PdfDocumentOpenMode.Modify), I get a System.InvalidOperationException thrown in the FinishChildReferences method. I believe it is because the method is enumerating through the dictionary.Elements, but then modifies a value in the Elements property.
`static void FinishChildReferences(PdfDictionary dictionary, PdfDocument document, HashSet finishedObjects)
{
foreach (var element in dictionary.Elements)
{
var item = element.Value;
`
Expected Behavior
Using Version 1.50.5147, PdfReader.Open loaded the pdf file successfully.
Actual Behavior
After updating to 6.1.0-preview-1, System.InvalidOperationException gets thrown.
Steps to Reproduce the Behavior
Call the following code:
var doc = PdfReader.Open(sourcePath, PdfDocumentOpenMode.Modify);
Pdf file to follow.