Problem: When Assigning a value to Aspose.Words.Bookmark.Text when a second bookmark exists (See Attached FiveBookmarks.doc) with the same position I am intermittently getting three different results, two of which appear to be bugs.
1) After assigning a value to Aspose.Words.Bookmark.Text using a for each loop, one of the bookmark items in the Document.Range.Bookmarks collection vanishes. (90% of the time).
2) I get the attached error (See attachment Error.txt) "Aspose.Words.PleaseReportException : Cannot find bookmark..."
3) Everything works as expected (this rarely happens)
Sample Code....
#region TestBookmark.TestPopulateBookmarksBug()
[Test()]
public void TestPopulateBookmarksBug()
{
FormDefinition formDefinition = TestFormDefinition.FormDefinitionFactory(TestHelper.GetUnderwritingCompany);
FormDefinitionVersion formDefinitionVersion = formDefinition.Versions[0];
formDefinitionVersion.FileName = FiveBookmarkDocument;
MicrosoftWordWrapper microsoftWordWrapper = new MicrosoftWordWrapper(formDefinitionVersion);
Dictionary<string, string> bookmarks = microsoftWordWrapper.BookMarks;
CreateBookmarks(bookmarks, formDefinitionVersion);
//Count is 6
int countBefore = microsoftWordWrapper.BookMarks.Count;
microsoftWordWrapper.TestPopulateBookmarksWithDataBug();
//Count suddenly becomes 5
//One of the bookmards in the Document vanishes
int countAfter = microsoftWordWrapper.BookMarks.Count;
Assert.AreEqual(countBefore, countAfter);
}
#endregion
#region MicrosoftWordWrapper.TestPopulateBookmarksWithDataBug()
public void TestPopulateBookmarksWithDataBug()
{
foreach (Aspose.Words.Bookmark wordBookmark in Document.Range.Bookmarks)
{
wordBookmark.Text = string.Empty;
}
}
#endregion