From 40844ad298af4cca6c60dfde29397f672fc05416 Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Wed, 7 Nov 2012 17:23:58 +0000 Subject: QPID-4427 C++ Messaging Client .NET Binding failed to wrap receiver.close(). Also add exception handler to closing section of map callback receiver example. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1406725 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/bindings/qpid/dotnet/configure-windows.ps1 | 4 +-- .../csharp.map.callback.receiver.cs | 14 ++++++++-- cpp/bindings/qpid/dotnet/src/Receiver.cpp | 31 +++++++++++++++++++--- 3 files changed, 42 insertions(+), 7 deletions(-) (limited to 'cpp') diff --git a/cpp/bindings/qpid/dotnet/configure-windows.ps1 b/cpp/bindings/qpid/dotnet/configure-windows.ps1 index 162ac272b4..17c2d486db 100644 --- a/cpp/bindings/qpid/dotnet/configure-windows.ps1 +++ b/cpp/bindings/qpid/dotnet/configure-windows.ps1 @@ -496,7 +496,7 @@ if ($make32) { $env:BOOST_ROOT = "$boost32" cd "$build32" Write-Host "Running 32-bit CMake in $build32 ..." - CMake -G "$global:cmakeGenerator" "-DCMAKE_INSTALL_PREFIX=install_x86" $cppDir + CMake -G "$global:cmakeGenerator" "-DGEN_DOXYGEN=No" "-DCMAKE_INSTALL_PREFIX=install_x86" $cppDir } else { Write-Host "Skipped 32-bit CMake." } @@ -508,7 +508,7 @@ if ($make64) { $env:BOOST_ROOT = "$boost64" cd "$build64" Write-Host "Running 64-bit CMake in $build64" - CMake -G "$global:cmakeGenerator Win64" "-DCMAKE_INSTALL_PREFIX=install_x64" $cppDir + CMake -G "$global:cmakeGenerator Win64" "-DGEN_DOXYGEN=No" "-DCMAKE_INSTALL_PREFIX=install_x64" $cppDir } else { Write-Host "Skipped 64-bit CMake." } diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs index 72ddd44120..3bc22b2ce8 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs @@ -162,6 +162,7 @@ namespace Org.Apache.Qpid.Messaging.Examples /// The exception. public void SessionException(Exception exception) { + // A typical application will take more action here. Console.WriteLine("{0} Exception caught.", exception.ToString()); } @@ -273,8 +274,17 @@ namespace Org.Apache.Qpid.Messaging.Examples // // Close the receiver and the connection. // - receiver.Close(); - connection.Close(); + try + { + receiver.Close(); + connection.Close(); + } + catch (Exception exception) + { + // receiver or connection may throw if they closed in error. + // A typical application will take more action here. + Console.WriteLine("{0} Closing exception caught.", exception.ToString()); + } return 0; } } diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp index bbd7dd4c52..43bb7dd3cb 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -344,9 +344,34 @@ namespace Messaging { void Receiver::Close() { - msclr::lock lk(privateLock); - ThrowIfDisposed(); + System::Exception ^ newException = nullptr; + Message ^ newMessage = nullptr; - nativeObjPtr->close(); + try + { + msclr::lock lk(privateLock); + ThrowIfDisposed(); + + nativeObjPtr->close(); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + finally + { + if (newException != nullptr) + { + if (newMessage != nullptr) + { + delete newMessage; + } + } + } + if (newException != nullptr) + { + throw newException; + } } }}}} -- cgit v1.2.1