FaultException implements Serializable but does not use serialization constructors
See original GitHub issueDescribe the bug As part of #3984 FaultException was marked Serializable which was released in System.ServiceModel.Primitives 4.8.0 However I am still not able to use the use case as described by Wouter. Using code that serializes FaultExceptions using remoting. After updating my dependency on System.ServiceModel.Primitives I still receive the stack trace
Failed to deserialize and get remote exception System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.ServiceModel.CommunicationException..ctor(SerializationInfo info, StreamingContext context)
at System.ServiceModel.FaultException..ctor(SerializationInfo info, StreamingContext context)
at System.ServiceModel.FaultException`1..ctor(SerializationInfo info, StreamingContext context)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(BinaryParser serParser, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, Boolean check)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at Microsoft.ServiceFabric.Services.Remoting.V2.RemoteException.TryDeserializeException(Stream data, Exception& result)
As far as I can tell that is because protected FaultException(SerializationInfo info, StreamingContext context)
throws a PlatformNotSupportedException
In reference source that method is implemented https://github.com/microsoft/referencesource/blob/5697c29004a34d80acdaf5742d7e699022c64ecd/System.ServiceModel/System/ServiceModel/FaultException.cs#L120
The scenario is the same as described by Wouter in the referenced issue. Is this something that also needs to be taken into account?
Thanks in advance, Regards, Max
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:7 (1 by maintainers)
@jnyrup Cool thanks for Sharing.
I also just created a quick example
The above example demonstrates that both using BinaryFormatter and DataContractSerializer serialization appears to be working. In all cases deserialization fails on the PlatformNotSupportedException.
Since our use case is to serialize the exception between services and then recreate them by deserializing to again have the Fault in the context of the service, we are unable to proceed with out use case at the moment
Here’s a complete repro that shows the difference between using:
FaultExceptionTests.zip