System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified - by Roberto Montoya

Status : 

 


2
0
Sign in
to vote
ID 769775 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/2/2012 9:34:21 AM
Access Restriction Public

Description

We have a WCF service hosted in IIS that creates flow documents.  This service runs fine but after several days of processing we run into the following error:

System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
   at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
   at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
   at System.Windows.SystemResources.EnsureResourceChangeListener()
   at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
   at System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce)
   at System.Windows.FrameworkContentElement.UpdateThemeStyleProperty()
   at System.Windows.FrameworkContentElement.OnInitialized(EventArgs e)
   at System.Windows.FrameworkContentElement.TryFireInitialized()
   at System.Windows.FrameworkContentElement.AddLogicalChild(Object child)
   at System.Windows.LogicalTreeHelper.AddLogicalChild(DependencyObject parent, Object child)
   at System.Windows.Documents.TextContainer.InsertElementInternal(TextPointer startPosition, TextPointer endPosition, TextElement element)
   at System.Windows.Documents.TextElement.RepositionWithContent(TextPointer textPosition)
   at System.Windows.Documents.TextElementCollection`1.Add(TextElementType item)
   at System.Windows.Documents.Span..ctor(Inline childInline, TextPointer insertionPosition)
   at System.Windows.Documents.Bold..ctor(Inline childInline)


Our code is constructing a Bold object like this:

new Bold(new Run(pageTitle))

pageTitle is a string.

We also see the following error around the same time:

http://connect.microsoft.com/VisualStudio/feedback/details/620588/system-componentmodel-win32exception-0x80004005-not-enough-storage-is-available-to-process-this-command

with this stack:

System.ComponentModel.Win32Exception (0x80004005): Not enough storage is available to process this command
   at MS.Win32.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
   at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
   at System.Windows.Threading.Dispatcher..ctor()
   at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
   at System.Windows.DependencyObject..ctor()
   at System.Windows.FrameworkContentElement..ctor()
   at System.Windows.Documents.FlowDocument..ctor()

This is the same area of our code.
Sign in to post a comment.
Posted by Microsoft on 7/2/2013 at 5:54 PM
This is the app's bug. Many threads do something that requires a Dispatcher (in your case, calling new Bold(new Run(pageTitle)) ), creating a new Dispatcher for each thread. But none of the threads shut down its Dispatcher (e.g. calling Dispatcher.InvokeShutdown). Eventually this runs out of a finite OS resource like window handles or queue space for window messages, leading to the (admittedly unhelpful) errors you're seeing.

It is the app's responsibility to shutdown each dispatcher it creates.
Posted by Microsoft on 11/2/2012 at 9:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)