방금 디버깅하는 동안 문제가 발생했습니다. kernel32.dll의 메서드를 사용하여 사용 가능한 RAM을 얻었지만 System.EngineExecutionException을 throw하지만 어쨌든 디버거가 중지됩니다. 예외로하고 계속하기를 거절합니다. 그런데 예외가 붙잡히지 않는 이유는 무엇입니까?왜 내 예외가 붙잡히지 않습니까?
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace StationController.Diagnose
{
public class Memorystatus
{
public UInt32 Length;
public UInt32 MemoryLoad;
public UInt32 TotalPhys;
public UInt32 AvailPhys;
public UInt32 TotalPageFile;
public UInt32 AvailPageFile;
public UInt32 TotalVirtual;
public UInt32 AvailVirtual;
}
class Test
{
[DllImport("kernel32")]
private static extern void GlobalMemoryStatus(ref Memorystatus buf);
private static UInt32 GetFreeRAM()
{
try
{
Memorystatus MemStat=new Memorystatus();
GlobalMemoryStatus(ref MemStat);
}
catch (System.ExecutionEngineException){ return 0; }
catch (System.Exception) { return 0; }
catch { return 0; } //I know kind of redundant
return sMemStat.AvailPhys;
}
}
}
도구 - 옵션을> -> 이미 예외에 대한 이유를 고정
, MEMORYSTATUS하지 구조체 클래스이어야 선택 해제 "예외가 외부 응용 프로그램 도메인을 때 정지",이 질문에 대한 것입니다 try-catch 동작
가능한 중복 [EngineExecutionException을 잡기] (http://stackoverflow.com/questions/9182387/catching-engineexecutionexception) –