From 2e524d021828d6d906f586e0faff9331e6fb9db4 Mon Sep 17 00:00:00 2001 From: tkyle <16074095+tkyle@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:05:31 -0600 Subject: [PATCH] #3235 Fix issue with null reference when throwing exception (backport to version 7) (#4301) Co-authored-by: tkyle Co-authored-by: Rockford Lhotka --- Source/Csla/DataPortalClient/HttpProxy.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Csla/DataPortalClient/HttpProxy.cs b/Source/Csla/DataPortalClient/HttpProxy.cs index 6b6de07e67..113ff85390 100644 --- a/Source/Csla/DataPortalClient/HttpProxy.cs +++ b/Source/Csla/DataPortalClient/HttpProxy.cs @@ -159,8 +159,16 @@ private byte[] CallViaWebClient(byte[] serialized, string operation, string rout catch (WebException ex) { string message; - using (var reader = new System.IO.StreamReader(ex.Response.GetResponseStream())) - message = reader.ReadToEnd(); + if (ex.Response != null) + { + using (var reader = new System.IO.StreamReader(ex.Response.GetResponseStream())) + message = reader.ReadToEnd(); + } + else + { + message = ex.Message; + } + throw new DataPortalException(message, ex); } }