Skip to content

Commit 6e87f5a

Browse files
Add Serializable attribute to WCF Exception classes.
1 parent ccb3371 commit 6e87f5a

26 files changed

+165
-4
lines changed

src/System.Private.ServiceModel/src/Internals/System/Runtime/FatalException.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.Runtime
78
{
9+
[Serializable]
810
internal class FatalException : Exception
911
{
1012
public FatalException()
@@ -20,5 +22,9 @@ public FatalException(string message, Exception innerException) : base(message,
2022
// throwing the fatal exception that was requested.
2123
Fx.Assert(innerException == null || !Fx.IsFatal(innerException), "FatalException can't be used to wrap fatal exceptions.");
2224
}
25+
26+
protected FatalException(SerializationInfo info, StreamingContext context) : base(info, context)
27+
{
28+
}
2329
}
2430
}

src/System.Private.ServiceModel/src/Internals/System/Runtime/Fx.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Reflection;
1111
using System.Runtime.CompilerServices;
1212
using System.Runtime.Diagnostics;
13+
using System.Runtime.Serialization;
1314
using System.Security;
1415
using System.ServiceModel;
1516

@@ -1006,20 +1007,32 @@ private void UnhandledExceptionFrame(IAsyncResult result)
10061007
}
10071008
}
10081009

1010+
[Serializable]
10091011
internal class InternalException : Exception
10101012
{
10111013
public InternalException(string description)
10121014
: base(InternalSR.ShipAssertExceptionMessage(description))
10131015
{
10141016
}
1017+
1018+
protected InternalException(SerializationInfo info, StreamingContext context)
1019+
: base(info, context)
1020+
{
1021+
}
10151022
}
10161023

1024+
[Serializable]
10171025
internal class FatalInternalException : InternalException
10181026
{
10191027
public FatalInternalException(string description)
10201028
: base(description)
10211029
{
10221030
}
1031+
1032+
protected FatalInternalException(SerializationInfo info, StreamingContext context)
1033+
: base(info, context)
1034+
{
1035+
}
10231036
}
10241037
}
10251038
}

src/System.Private.ServiceModel/src/System/IdentityModel/SecurityMessageSerializationException.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.IdentityModel
78
{
9+
[Serializable]
810
public class SecurityMessageSerializationException : Exception
911
{
1012
public SecurityMessageSerializationException()
@@ -21,5 +23,10 @@ public SecurityMessageSerializationException(String message, Exception innerExce
2123
: base(message, innerException)
2224
{
2325
}
26+
27+
protected SecurityMessageSerializationException(SerializationInfo info, StreamingContext context)
28+
: base(info, context)
29+
{
30+
}
2431
}
2532
}

src/System.Private.ServiceModel/src/System/IdentityModel/Tokens/SecurityTokenException.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.IdentityModel.Tokens
78
{
9+
[Serializable]
810
public class SecurityTokenException : Exception
911
{
1012
public SecurityTokenException()
@@ -21,5 +23,10 @@ public SecurityTokenException(String message, Exception innerException)
2123
: base(message, innerException)
2224
{
2325
}
26+
27+
protected SecurityTokenException(SerializationInfo info, StreamingContext context)
28+
: base(info, context)
29+
{
30+
}
2431
}
2532
}

src/System.Private.ServiceModel/src/System/IdentityModel/Tokens/SecurityTokenValidationException.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.IdentityModel.Tokens
78
{
9+
[Serializable]
810
public class SecurityTokenValidationException : SecurityTokenException
911
{
1012
public SecurityTokenValidationException()
@@ -21,5 +23,10 @@ public SecurityTokenValidationException(String message, Exception innerException
2123
: base(message, innerException)
2224
{
2325
}
26+
27+
protected SecurityTokenValidationException(SerializationInfo info, StreamingContext context)
28+
: base(info, context)
29+
{
30+
}
2431
}
2532
}

src/System.Private.ServiceModel/src/System/ServiceModel/ActionMismatchAddressingException.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
65
using System.Runtime;
6+
using System.Runtime.Serialization;
77
using System.ServiceModel.Channels;
88

99
namespace System.ServiceModel
1010
{
11+
[Serializable]
1112
internal class ActionMismatchAddressingException : ProtocolException
1213
{
1314
private string _httpActionHeader;
@@ -20,6 +21,11 @@ public ActionMismatchAddressingException(string message, string soapActionHeader
2021
_soapActionHeader = soapActionHeader;
2122
}
2223

24+
protected ActionMismatchAddressingException(SerializationInfo info, StreamingContext context)
25+
: base(info, context)
26+
{
27+
}
28+
2329
public string HttpActionHeader
2430
{
2531
get

src/System.Private.ServiceModel/src/System/ServiceModel/ActionNotSupportedException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44

55

66
using System.Diagnostics.Contracts;
7+
using System.Runtime.Serialization;
78
using System.ServiceModel.Channels;
89

910
namespace System.ServiceModel
1011
{
12+
[Serializable]
1113
public class ActionNotSupportedException : CommunicationException
1214
{
1315
public ActionNotSupportedException() { }
1416
public ActionNotSupportedException(string message) : base(message) { }
1517
public ActionNotSupportedException(string message, Exception innerException) : base(message, innerException) { }
18+
protected ActionNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
1619

1720
internal Message ProvideFault(MessageVersion messageVersion)
1821
{

src/System.Private.ServiceModel/src/System/ServiceModel/ChannelTerminatedException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.ServiceModel
78
{
9+
[Serializable]
810
public class ChannelTerminatedException : CommunicationException
911
{
1012
public ChannelTerminatedException() { }
1113
public ChannelTerminatedException(string message) : base(message) { }
1214
public ChannelTerminatedException(string message, Exception innerException) : base(message, innerException) { }
15+
protected ChannelTerminatedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
1316
}
1417
}

src/System.Private.ServiceModel/src/System/ServiceModel/CommunicationException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.ServiceModel
78
{
9+
[Serializable]
810
public class CommunicationException : Exception
911
{
1012
public CommunicationException() { }
1113
public CommunicationException(string message) : base(message) { }
1214
public CommunicationException(string message, Exception innerException) : base(message, innerException) { }
15+
protected CommunicationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
1316
}
1417
}

src/System.Private.ServiceModel/src/System/ServiceModel/CommunicationObjectAbortedException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Runtime.Serialization;
56

67
namespace System.ServiceModel
78
{
9+
[Serializable]
810
public class CommunicationObjectAbortedException : CommunicationException
911
{
1012
public CommunicationObjectAbortedException() { }
1113
public CommunicationObjectAbortedException(string message) : base(message) { }
1214
public CommunicationObjectAbortedException(string message, Exception innerException) : base(message, innerException) { }
15+
protected CommunicationObjectAbortedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
1316
}
1417
}

0 commit comments

Comments
 (0)