編譯器錯誤 C2749
'type' : 只能使用 /clr:safe 擲回或攔截 Managed 類別的句柄
使用 /clr:safe 時,您只能擲回或攔截參考類型。
如需詳細資訊,請參閱 /clr (Common Language Runtime 編譯)。
範例
下列範例會產生 C2749:
// C2749.cpp
// compile with: /clr:safe
ref struct MyStruct {
public:
int i;
};
int main() {
MyStruct ^x = gcnew MyStruct;
// Delete the following 4 lines to resolve.
try {
throw (1); // C2749
}
catch(int){}
// OK
try {
throw (x);
}
catch(MyStruct ^){}
}