Kompilatorfel C2749

"type" : kan bara kasta eller fånga handtag till en hanterad klass med /clr:safe

Anmärkningar

När du använder /clr:safe kan du bara kasta eller fånga en referenstyp.

Mer information finns i /clr (Common Language Runtime Compilation).

Exempel

I följande exempel genereras 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 ^){}
}