Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
C/C++ Build Errors
 Compiler Error C2725

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual C++ Concepts: Building a C/C++ Program
Compiler Error C2725

Error Message

'exception' : unable to throw or catch a managed object by value or reference

The type of a managed exception was not correct.

Example

The following sample generates C2725.

// C2725.cpp
// compile with: /clr
ref class R {
public:
   int i;
};

int main() {
   R % r1 = *gcnew R;
   throw r1;   // C2725

   R ^ r2 = gcnew R;
   throw r2;   // OK   
}

The following sample generates C2725.

// C2725b.cpp
// compile with: /clr
using namespace System;
int main() {
   try {}
   catch( System::Exception%) {}   // C2725
   // try the following line instead
   // catch( System::Exception ^e) {}
}

The following sample generates C2725.

// C2725c.cpp
// compile with: /clr:oldSyntax
using namespace System;
int main() {
   try {}
   catch( System::Exception&) {}   // C2725
   // try the following line instead
   // catch( System::Exception *e) {}
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker