现在来看WPF里的另外一个BUG
新建一个任意(非asp.net)项目,并且添加Microsoft.ReportViewer.Common、Microsoft.ReportViewer.WinForms、System.Windows.Forms 和PresentationFramework 程序集。
Program.cs写入如下代码:
namespace
ConsoleApplication1
{
class Program
{
static void Main( string [] args)
{
System.Windows.Markup.XamlWriter.Save( new Microsoft.Reporting.WinForms.ReportViewer());
}
}
}
{
class Program
{
static void Main( string [] args)
{
System.Windows.Markup.XamlWriter.Save( new Microsoft.Reporting.WinForms.ReportViewer());
}
}
}
运行后一样的抛出“StackOverflowException”。
如果加上try...catch...语句,效果是一样的,无法捕获到异常。只会在Console得到
Process is terminated due to StackOverflowException
.
如果说这是non-CLSCompliant exceptions那么我们可以配置开启legacyCorruptedStateExceptionsPolicy。
<?
xml version="1.0"
?>
< configuration >
< runtime >
< legacyCorruptedStateExceptionsPolicy enabled ="true" />
</ runtime >
</ configuration >
< configuration >
< runtime >
< legacyCorruptedStateExceptionsPolicy enabled ="true" />
</ runtime >
</ configuration >
开启后一样会“StackOverflowException”。
至于这是什么状况导致开启了 legacyCorruptedStateExceptionsPolicy 也无法捕获到这个异常,希望有朋友能够帮助大家解答。
或者,这本身就是微软 .NET 框架的 BUG ?