title: An unhandled exception of type 'System.InvalidOperationException' occurred in System.Core.dll
body: <pre><code>Window owner = System.Windows.Application.Current.Windows.OfType&lt;Window&gt;().SingleOrDefault(x =&gt; x.IsActive);
  if (owner == null)
      owner = System.Windows.Application.Current.Windows.OfType&lt;Window&gt;().SingleOrDefault();
  </code></pre>
  
  <p>On execution of last line,I am getting the error as:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.InvalidOperationException' occurred in System.Core.dll</p>
  </blockquote>
  
  <p>This error is coming once I upgraded from VisualStudio 2012 to VisualStudio 2015.</p>
  
  <p>What Configuration I have to do to resolve this error?</p>