-
Notifications
You must be signed in to change notification settings - Fork 482
Description
I'm encountering an error when merging DOCX files. The exception thrown is System.InvalidOperationException: Sequence contains no elements, which happens with some files I add to the merge list.
I downloaded the source code to investigate the issue, and it turns out that the files causing the problem apparently do not have custom properties, leading to an error in this block:
`IEnumerable pids =
(
from d in remote_custom_document.Root.Descendants()
where d.Name.LocalName == "property"
select int.Parse( d.Attribute( XName.Get( "pid" ) ).Value )
);
int pid = pids.Max() + 1;`
I fixed the issue by checking if pids contains any elements and setting the value to 1 if it doesn't:
int pid = pids.Any() ? pids.Max() + 1 : 1;
I don't know much about the internal structure of DOCX files, so I’d like to ask: Is this fix valid? If so, should I submit a PR to fix it?"