Compiler Error C3274
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3274.
__finally/finally without matching try
A __finally or finally statement was found without a matching try. To resolve this, either delete the __finally statement or add a try statement for the __finally.
The following sample generates C3274:
// C3274.cpp
// compile with: /clr
// C3274 expected
using namespace System;
int main() {
try {
try {
throw gcnew ApplicationException();
}
catch(...) {
Console::Error->WriteLine(L"Caught an exception");
}
finally {
Console::WriteLine(L"In finally");
}
} finally {
Console::WriteLine(L"In finally");
}
// Uncomment the following 3 lines to resolve.
// try {
// throw gcnew ApplicationException();
// }
finally {
Console::WriteLine(L"In finally");
}
Console::WriteLine(L"**FAIL**");
}
Show: