Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOException using WPF DocumentViewer to search contents #7567

Closed
pchaurasia14 opened this issue Feb 23, 2023 · 0 comments · Fixed by #7568
Closed

IOException using WPF DocumentViewer to search contents #7567

pchaurasia14 opened this issue Feb 23, 2023 · 0 comments · Fixed by #7568
Assignees
Labels
🚧 work in progress Investigate Requires further investigation by the WPF team.

Comments

@pchaurasia14
Copy link
Member

Description

When using DocumentViewer control, repeated search for any text throws an IOException.

Message - 
    System.IO.IOException: 'Entries cannot be opened multiple times in Update mode
Stack Trace -
    at System.IO.Compression.ZipArchiveEntry.OpenInUpdateMode()
   at System.IO.Compression.ZipArchiveEntry.Open()
   at System.IO.Packaging.ZipStreamManager.Open(ZipArchiveEntry zipArchiveEntry, FileMode streamFileMode, FileAccess streamFileAccess)
   at System.IO.Packaging.ZipPackagePart.GetStreamCore(FileMode streamFileMode, FileAccess streamFileAccess)
   at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
   at MS.Internal.IO.Packaging.PackagePartExtensions.GetSeekableStream(PackagePart packPart, FileMode mode, FileAccess access)
   at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
   at System.IO.Packaging.PackWebResponse.GetResponseStream()
   at MS.Internal.WpfWebRequestHelper.CreateRequestAndGetResponseStream(Uri uri)
   at System.Windows.Documents.PageContent.GetPageStream()
   at System.Windows.Documents.FixedFindEngine._GetPageString(FixedDocument doc, Int32 translatedPageNo, Boolean replaceAlefWithAlefHamza)
   at System.Windows.Documents.FixedFindEngine.Find(ITextPointer start, ITextPointer end, String findPattern, CultureInfo cultureInfo, Boolean matchCase, Boolean matchWholeWord, Boolean matchLast, Boolean matchDiacritics, Boolean matchKashida, Boolean matchAlefHamza)
   at System.Windows.Documents.TextFindEngine.Find(ITextPointer findContainerStartPosition, ITextPointer findContainerEndPosition, String findPattern, FindFlags flags, CultureInfo cultureInfo)
   at MS.Internal.Documents.DocumentViewerHelper.Find(FindToolBar findToolBar, TextEditor textEditor, ITextView textView, ITextView masterPageTextView)
   at System.Windows.Controls.Primitives.DocumentViewerBase.Find(FindToolBar findToolBar)
   at System.Windows.Controls.DocumentViewer.OnFindInvoked(Object sender, EventArgs e)
   at MS.Internal.Documents.FindToolBar.OnFindTextBoxPreviewKeyDown(Object sender, KeyEventArgs e)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   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)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at DocumentViewerException.App.Main()

Reproduction Steps

  1. Use a machine with Visual Studio 2022
  2. Unzip the attached sample DocumentViewerExceptionRepro.zip
  3. Build and run the application
  4. At the bottom of the main window there is a search control
  5. search for any string and press the same search button multiple times

Expected behavior

Should not throw exception

Actual behavior

Throws exception

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

.NET Core 6, 7

Other information

DocumentViewerException.zip

@pchaurasia14 pchaurasia14 self-assigned this Feb 23, 2023
@pchaurasia14 pchaurasia14 added the Investigate Requires further investigation by the WPF team. label Feb 23, 2023
@ghost ghost removed the 🚧 work in progress label Apr 3, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🚧 work in progress Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant