StackOverflowExceptionとは? わかりやすく解説

StackOverflowException クラス

入れ子になったメソッド呼び出しが多くなりすぎ、実行スタックがオーバーフローした場合にスローされる例外。このクラスは継承できません。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 StackOverflowException
    Inherits SystemException
Dim instance As StackOverflowException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class StackOverflowException
 : SystemException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class StackOverflowException sealed
 : public SystemException
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class StackOverflowException extends
 SystemException
SerializableAttribute 
ComVisibleAttribute(true) 
public final class StackOverflowException extends
 SystemException
解説解説

StackOverflowException は、再帰の回数がかなり多い場合や無限に続く場合などに生じる、実行スタックのオーバーフローによるエラーに対してスローされます。MSIL (Microsoft Intermediate Language) の Localloc 命令は、StackOverflowException をスローします。

StackOverflowException は、値 0x800703E9 を保持する HRESULT COR_E_STACKOVERFLOW を使用します。StackOverflowException オブジェクトの初期プロパティ値の一覧については、StackOverflowException コンストラクタのトピックを参照してください。

メモメモ

継承された Data プロパティの値は常に null 参照 (Visual Basic では Nothing) です。

バージョンの考慮事項

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition プラットフォームメモ : スローされた StackOverflowException を try-catch ブロックでキャッチすることはできません。したがって、例外によってプロセスは即座に終了させられます。

継承階層継承階層
System.Object
   System.Exception
     System.SystemException
      System.StackOverflowException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackOverflowException コンストラクタ ()

StackOverflowException クラスの新しいインスタンスの Message プロパティに、"要求された操作によってスタック オーバーフローが発生しました。" などのエラーを説明するシステムから提供されるメッセージを設定して、その新しいインスタンスを初期化します。このメッセージは、システムの現在のカルチャを考慮して指定します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New StackOverflowException
public StackOverflowException ()
public:
StackOverflowException ()
public StackOverflowException ()
public function StackOverflowException ()
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
StackOverflowException クラス
StackOverflowException メンバ
System 名前空間

StackOverflowException コンストラクタ (String)

指定したエラー メッセージを使用して、StackOverflowException クラスの新しいインスタンスを初期化します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim message As String

Dim instance As New StackOverflowException(message)
public StackOverflowException (
    string message
)
public:
StackOverflowException (
    String^ message
)
public StackOverflowException (
    String message
)
public function StackOverflowException (
    message : String
)

パラメータ

message

エラーを説明する String。メッセージの内容は、ユーザーが理解できる内容にします。このコンストラクタの呼び出し元は、この文字列が現在のシステムのカルチャに合わせてローカライズ済みであることを確認しておく必要があります。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
StackOverflowException クラス
StackOverflowException メンバ
System 名前空間

StackOverflowException コンストラクタ (String, Exception)

指定したエラー メッセージと、この例外の原因である内部例外への参照を使用して、StackOverflowException クラスの新しいインスタンスを初期化します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    message As String, _
    innerException As Exception _
)
Dim message As String
Dim innerException As Exception

Dim instance As New StackOverflowException(message,
 innerException)
public StackOverflowException (
    string message,
    Exception innerException
)
public:
StackOverflowException (
    String^ message, 
    Exception^ innerException
)
public StackOverflowException (
    String message, 
    Exception innerException
)
public function StackOverflowException (
    message : String, 
    innerException : Exception
)

パラメータ

message

例外の原因を説明するエラー メッセージ。

innerException

現在の例外の原因である例外。innerException パラメータが null 参照 (Visual Basic の場合は Nothing) でない場合は、内部例外を処理する catch ブロックで現在の例外が発生します。

解説解説

前の例外の直接の結果としてスローされる例外については、InnerException プロパティに、前の例外への参照が格納されます。InnerException プロパティは、コンストラクタに渡されたものと同じ値を返します。InnerException プロパティによって内部例外値がコンストラクタに渡されなかった場合は、null 参照 (Visual Basic の場合は Nothing) を返します。

StackOverflowException のインスタンスの初期プロパティ値を次の表に示します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackOverflowException コンストラクタ


StackOverflowException プロパティ


StackOverflowException メソッド


StackOverflowException メンバ

入れ子になったメソッド呼び出しが多くなりすぎ、実行スタックがオーバーフローした場合にスローされる例外。このクラスは継承できません。

StackOverflowException データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド StackOverflowException オーバーロードされます。 StackOverflowException クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
参照参照

関連項目

StackOverflowException クラス
System 名前空間
Exception クラス

その他の技術情報

例外の処理とスロー



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「StackOverflowException」の関連用語

StackOverflowExceptionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



StackOverflowExceptionのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS