【发布时间】:2018-02-08 09:56:03
【问题描述】:
我基本上有一个重复的 question,但对于 .NET Core。
我有核心控制台应用程序:
class Program
{
static void DoSomeAccessViolation()
{
// if you have any questions about why this throws,
// the answer is "42", of course
var ptr = new IntPtr(42);
Marshal.StructureToPtr(42, ptr, true);
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
static void Main(string[] args)
{
try
{
DoSomeAccessViolation();
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
}
}
}
我已尝试添加 Settings.setting 文件
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ConsoleApp2" GeneratedClassName="Settings1">
<Profiles />
<Settings>
<Setting Name="legacyCorruptedStateExceptionsPolicy" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
我已经尝试根据docs设置环境变量:
C:\>set COMPlus_legacyCorruptedStateExceptionsPolicy=1
C:\>dotnet run
或
C:\>set COMPlus_legacyCorruptedStateExceptionsPolicy=true
C:\>dotnet run
(在 Windows 上)。但是没有任何效果,应用程序总是在不打印异常的情况下严重崩溃。
【问题讨论】:
-
它不会因 AVE 而崩溃。您无法收取费用。除了 CoreCLR 中的错误之外,很难将其称为任何错误,请考虑提交错误报告。
-
@JanHudecek 你有没有为此提交过错误?
标签: c# .net-core access-violation corrupted-state-exception