Exception
atexit の代わりにmain で finallyを記述して、System::Environment::Exit()のかわりに 例外をスローする。
int main(){
try{
someClass^ sc = gcnew someClass();
:
何かの処理 ()
:
} catch (自分で定義した例外クラス^ e){
// これをうけてやらないと System::Runtime::CompilerServices::RuntimeWrappedException がどうのこうのといってくる
} finally {
}
if( sc ) delete sc;
}
何かの処理(){
自分で定義した例外クラス^ e = gcnew e();
e->msg = "brabra";
throw e;
// 例外生成
}
// ErrorExit.h
//
#pragma once
#using <mscorlib.dll>
#using <System.dll>
ref class ErrorExit {
public:
System::String^ msg;
};
ErrorExit^ ex = gcnew ErrorExit();
ex->msg=msg;
throw ex;
Exception が拾えない例外
System::Runtime::CompilerServices::RuntimeWrappedException^ e