Ejemplo n.º 1
0
        void EvalSerializationException(ref SerializationException serex, Uri url, string method)
        {
            //note: when upgrading to .NET 4.5 or greater, switch from Message prop to HResult prop, value = {-2146233076}
            int hresultNullValueCode = -2146233076;
            int hresult = 0;

            System.Reflection.PropertyInfo hresultProp = serex.GetType().GetProperty("HResult",
                                                                                     System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static);
            if (hresultProp != null)
            {
                hresult = (int)hresultProp.GetValue(serex, null);
            }

            serex.Data.Add("SerializationException",
                           string.Format("Could not deserialize result from [{1}]: {0}.", url, method));
            serex.Data.Add("HResult", hresult);

            if (hresult == hresultNullValueCode ||
                serex.Message.StartsWith("Expecting element 'root' from namespace ''.. Encountered 'None'  with name '', namespace ''."))
            {
                serex.Data.Add("Resolution", "Check unexpected void/null return type/value from method.");
            }
            else
            {
                serex.Data.Add("Resolution", string.Format("Unknown error.", url, method));
            }
        }
Ejemplo n.º 2
0
 public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     if (error is FaultException)
     {
         SerializationException serException = error.InnerException as SerializationException;
         if (serException != null)
         {
             string detail = String.Format("{0}: {1}", serException.GetType().FullName, serException.Message);
             FaultException <string> faultException = new FaultException <string>(detail, new FaultReason("SerializationException caught while deserializing parameter from the client"));
             MessageFault            messageFault   = faultException.CreateMessageFault();
             //fault = Message.CreateMessage(version, messageFault, Dbs.FaultAction);
         }
     }
 }