컴파일러 오류 CS0155
업데이트: 2007년 11월
오류 메시지
Catch 또는 throw된 형식은 System.Exception에서 파생되어야 합니다.
The type caught or thrown must be derived from System.Exception
System.Exception에서 파생되지 않은 데이터 형식을 catch 블록에 전달하려고 했습니다. System.Exception에서 파생된 데이터 형식만 catch블록으로 전달할 수 있습니다. 자세한 내용은 예외 처리문 및 예외 및 예외 처리(C# 프로그래밍 가이드)를 참조하십시오.
다음 샘플에서는 CS0155 오류가 발생하는 경우를 보여 줍니다.
// CS0155.cs
using System;
namespace MyNamespace
{
public class MyClass2
// try the following line instead
// public class MyClass2 : Exception
{
}
public class MyClass
{
public static void Main()
{
try
{
}
catch (MyClass2) // CS0155, resolves if you derive MyClass2 from Exception
{
}
}
}
}