title: visual studio crashes randomly devenv KERNELBASE.dll
body: <p>My Visual Studio crashes randomly. Event Viewer shows the following error</p>
  
  <blockquote>
    <p>Faulting application name: devenv.exe, version: 12.0.40629.0, time
    stamp: 0x5590c8a4 </p>
    
    <p>Faulting module name: KERNELBASE.dll, version:
    10.0.15063.674, time stamp: 0x6d16dd24 </p>
    
    <p>Exception code: 0xe0434352 </p>
    
    <p>Fault offset: 0x000eb872 </p>
    
    <p>Faulting process id: 0x3b00 </p>
    
    <p>Faulting application start time: 0x01d34ecf7a049150 </p>
    
    <p>Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio
    12.0\Common7\IDE\devenv.exe </p>
    
    <p>Faulting module path: C:\Windows\System32\KERNELBASE.dll </p>
    
    <p>Report Id: xxxxxxxx-867c-4c54-b259-c28a7b9d8151 </p>
    
    <p>Faulting package full name: 
    Faulting package-relative application ID:</p>
  </blockquote>
  
  <p>I have tried running devenv /SAFEMODE command at (C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE)</p>
  
  <p>but still it keeps occuring and sometimes a dialog box also appears "<strong>not enough storage available</strong>"</p>
  
  <blockquote>
    <p>Application: devenv.exe</p>
    
    <p>Framework Version: v4.0.30319</p>
    
    <p>Description: The process was terminated due to an unhandled exception.</p>
    
    <p>Exception Info: System.ComponentModel.Win32Exception    at
    MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D)</p>
  </blockquote>
  
  <p><strong>Activity Log</strong></p>
  
  <p>(0x80004005): Not enough storage is available to process this command </p>
  
  <p>at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d) </p>
  
  <p>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) </p>
  
  <p>at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters) </p>
  
  <p>at System.Windows.Interop.HwndSource..ctor(HwndSourceParameters parameters) </p>
  
  <p>at System.Windows.Controls.Primitives.Popup.PopupSecurityHelper.BuildWindow(Int32 x, Int32 y, Visual placementTarget, Boolean transparent, HwndSourceHook hook, AutoResizedEventHandler handler) </p>
  
  <p>at System.Windows.Controls.Primitives.Popup.BuildWindow(Visual targetVisual) </p>
  
  <p>at System.Windows.Controls.Primitives.Popup.CreateWindow(Boolean asyncCall) </p>
  
  <p>at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) </p>
  
  <p>at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) </p>
  
  <p>at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) </p>
  
  <p>at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) </p>
  
  <p>at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry&amp; newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) </p>
  
  <p>at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)</p>
  
  <p>at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) </p>
  
  <p>at Microsoft.VisualStudio.Language.Intellisense.Implementation.MouseTrackingQuickInfoPresenter.Render() </p>
  
  <p>at Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseSessionStack.OnSessionPresenterChanged(Object sender, EventArgs e)</p>
  
  <p>at Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseSession.RaisePresenterChanged() </p>
  
  <p>at Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoSession.Recalculate() </p>
  
  <p>at Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoSession.Start() </p>
  
  <p>at Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoBroker.TriggerQuickInfo(ITextView textView, ITrackingPoint triggerPoint, Boolean trackMouse) </p>
  
  <p>at Microsoft.Html.Editor.HtmlQuickInfoController.OnMouseHover(Object sender, MouseHoverEventArgs e) </p>
  
  <p>at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.RaiseHoverEvents()</p>
  
  <h2>UPDATE</h2>
  
  <p>My Application runs for once or twice in <strong>safemode</strong> then even that exits. When trying to restart visual studio, it fails. Then event viewer or cmd prompt do not work and i have to restart my machine to make something work.</p>
  
  <h2>UPDATE 2</h2>
  
  <p>Looks like <a href="https://connect.microsoft.com/VisualStudio/feedback/details/620588/system-componentmodel-win32exception-0x80004005-not-enough-storage-is-available-to-process-this-command" rel="nofollow noreferrer">this</a> and <a href="https://stackoverflow.com/questions/41543956/how-to-debug-not-enough-storage-is-available-to-process-this-command/41544029#41544029">this</a> is my issue. Now How do i use Dispatcher in my code?</p>
  
  <pre><code>public string ConvertRtfToHtml(string rtfText)
      {
  
          try
          {
              var thread = new Thread(ConvertRtfInSTAThread);                
              var threadData = new ConvertRtfThreadData { RtfText = rtfText };
              thread.SetApartmentState(ApartmentState.STA);
              thread.Start(threadData);
  
              try
              {
                  thread.Join();
              }
              catch(ThreadStateException e){
                  logger.Error("ThreadStateException " + e.Message);
              }
              catch (ThreadInterruptedException e) {
                  logger.Error("ThreadInterruptedException " + e.Message);
              }                
  
  
              return threadData.HtmlText;
  
          }
          catch (Exception e){
              logger.Error("ConvertRtfToHtml: " + e.InnerException.Message);
              return "Error";
          }
  
      }
  </code></pre>
  
  <p>the <strong>ConvertRtfToHtml</strong> is being called from within a loop
  the <strong>ConvertRtfInSTAThread</strong> uses a RichTextBox control</p>