FaultException<TDetail> Constructores

Definición

Inicializa una nueva instancia de la clase FaultException<TDetail>.Initializes a new instance of the FaultException<TDetail> class.

Sobrecargas

FaultException<TDetail>(TDetail)

Inicializa una instancia nueva de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object.

FaultException<TDetail>(SerializationInfo, StreamingContext)

Inicializa una nueva instancia de la clase FaultException<TDetail> con los parámetros especificados: la información de serialización y el contexto al deserializar una secuencia en un objeto FaultException.Initializes a new instance of the FaultException<TDetail> class using the specified serialization information and context when deserializing a stream into a FaultException object.

FaultException<TDetail>(TDetail, FaultReason)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado y la razón del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object and fault reason.

FaultException<TDetail>(TDetail, String)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el detalle especificado y la razón del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail and fault reason.

FaultException<TDetail>(TDetail, FaultReason, FaultCode)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error y el código del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, fault reason, and fault code.

FaultException<TDetail>(TDetail, String, FaultCode)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error y el código del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, fault reason, and fault code.

FaultException<TDetail>(TDetail, FaultReason, FaultCode, String)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error de SOAP, el código y los valores de la acción.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, and SOAP fault reason, code and action values.

FaultException<TDetail>(TDetail, String, FaultCode, String)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error de SOAP, el código y los valores de la acción.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, and SOAP fault reason, code and action values.

FaultException<TDetail>(TDetail)

Inicializa una instancia nueva de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object.

public:
 FaultException(TDetail detail);
public FaultException (TDetail detail);
new System.ServiceModel.FaultException<'Detail> : 'Detail -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

Ejemplos

El ejemplo de código siguiente muestra cómo utiliza un servicio el tipo FaultException<TDetail> para producir una excepción administrada que se convierte en el error de SOAP especificado por FaultContractAttribute.The following code example shows how a service uses the FaultException<TDetail> type to throw a managed exception that gets converted into the SOAP fault specified by the FaultContractAttribute.

using System;
using System.Collections.Generic;
using System.Net.Security;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace Microsoft.WCF.Documentation
{
  [ServiceContract(Namespace="http://microsoft.wcf.documentation")]
  public interface ISampleService{
    [OperationContract]
    [FaultContractAttribute(
      typeof(GreetingFault),
      Action="http://www.contoso.com/GreetingFault",
      ProtectionLevel=ProtectionLevel.EncryptAndSign
      )]
    string SampleMethod(string msg);
  }

  [DataContractAttribute]
  public class GreetingFault
  {
    private string report;

    public GreetingFault(string message)
    {
      this.report = message;
    }

    [DataMemberAttribute]
    public string Message
    {
      get { return this.report; }
      set { this.report = value; }
    }
  }

  class SampleService : ISampleService
  {
  #region ISampleService Members

  public string  SampleMethod(string msg)
  {
    Console.WriteLine("Client said: " + msg);
    // Generate intermittent error behavior.
    Random rnd = new Random(DateTime.Now.Millisecond);
    int test = rnd.Next(5);
    if (test % 2 != 0)
      return "The service greets you: " + msg;
    else
      throw new FaultException<GreetingFault>(new GreetingFault("A Greeting error occurred. You said: " + msg));
  }

  #endregion
  }
}

Imports System.Collections.Generic
Imports System.Net.Security
Imports System.Runtime.Serialization
Imports System.ServiceModel
Imports System.Text

Namespace Microsoft.WCF.Documentation
  <ServiceContract(Namespace:="http://microsoft.wcf.documentation")> _
  Public Interface ISampleService
    <OperationContract, FaultContractAttribute(GetType(GreetingFault), Action:="http://www.contoso.com/GreetingFault", ProtectionLevel:=ProtectionLevel.EncryptAndSign)> _
    Function SampleMethod(ByVal msg As String) As String
  End Interface

  <DataContractAttribute> _
  Public Class GreetingFault
    Private report As String

    Public Sub New(ByVal message As String)
      Me.report = message
    End Sub

    <DataMemberAttribute> _
    Public Property Message() As String
      Get
          Return Me.report
      End Get
      Set(ByVal value As String)
          Me.report = value
      End Set
    End Property
  End Class

  Friend Class SampleService
      Implements ISampleService
  #Region "ISampleService Members"

  Public Function SampleMethod(ByVal msg As String) As String Implements ISampleService.SampleMethod
    Console.WriteLine("Client said: " & msg)
    ' Generate intermittent error behavior.
    Dim rand As New Random(DateTime.Now.Millisecond)
    Dim test As Integer = rand.Next(5)
    If test Mod 2 <> 0 Then
      Return "The service greets you: " & msg
    Else
      Throw New FaultException(Of GreetingFault)(New GreetingFault("A Greeting error occurred. You said: " & msg))
    End If
  End Function

  #End Region
  End Class
End Namespace

Comentarios

El objeto de detalle debe ser serializable o se produce una excepción cuando se serializa FaultException<TDetail>.The detail object must be serializable or an exception is thrown when the FaultException<TDetail> is serialized.

Se aplica a

FaultException<TDetail>(SerializationInfo, StreamingContext)

Inicializa una nueva instancia de la clase FaultException<TDetail> con los parámetros especificados: la información de serialización y el contexto al deserializar una secuencia en un objeto FaultException.Initializes a new instance of the FaultException<TDetail> class using the specified serialization information and context when deserializing a stream into a FaultException object.

protected:
 FaultException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected FaultException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.ServiceModel.FaultException<'Detail> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.ServiceModel.FaultException<'Detail>
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parámetros

info
SerializationInfo

La información de serialización necesaria para reconstruir el objeto FaultException a partir de context.The serialization information necessary to reconstruct the FaultException object from the context.

context
StreamingContext

La secuencia desde la que reconstruir el objeto FaultException.The stream from which to reconstruct the FaultException object.

Se aplica a

FaultException<TDetail>(TDetail, FaultReason)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado y la razón del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object and fault reason.

public:
 FaultException(TDetail detail, System::ServiceModel::FaultReason ^ reason);
public FaultException (TDetail detail, System.ServiceModel.FaultReason reason);
new System.ServiceModel.FaultException<'Detail> : 'Detail * System.ServiceModel.FaultReason -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail, reason As FaultReason)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

reason
FaultReason

La razón del error de SOAP.The reason for the SOAP fault.

Se aplica a

FaultException<TDetail>(TDetail, String)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el detalle especificado y la razón del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail and fault reason.

public:
 FaultException(TDetail detail, System::String ^ reason);
public FaultException (TDetail detail, string reason);
new System.ServiceModel.FaultException<'Detail> : 'Detail * string -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail, reason As String)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

reason
String

La razón del error de SOAP.The reason for the SOAP fault.

Se aplica a

FaultException<TDetail>(TDetail, FaultReason, FaultCode)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error y el código del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, fault reason, and fault code.

public:
 FaultException(TDetail detail, System::ServiceModel::FaultReason ^ reason, System::ServiceModel::FaultCode ^ code);
public FaultException (TDetail detail, System.ServiceModel.FaultReason reason, System.ServiceModel.FaultCode code);
new System.ServiceModel.FaultException<'Detail> : 'Detail * System.ServiceModel.FaultReason * System.ServiceModel.FaultCode -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail, reason As FaultReason, code As FaultCode)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

reason
FaultReason

La razón del error de SOAP.The reason for the SOAP fault.

code
FaultCode

El código de error para el error de SOAP.The fault code for the SOAP fault.

Se aplica a

FaultException<TDetail>(TDetail, String, FaultCode)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error y el código del error.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, fault reason, and fault code.

public:
 FaultException(TDetail detail, System::String ^ reason, System::ServiceModel::FaultCode ^ code);
public FaultException (TDetail detail, string reason, System.ServiceModel.FaultCode code);
new System.ServiceModel.FaultException<'Detail> : 'Detail * string * System.ServiceModel.FaultCode -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail, reason As String, code As FaultCode)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

reason
String

La razón del error de SOAP.The reason for the SOAP fault.

code
FaultCode

El código de error para el error de SOAP.The fault code for the SOAP fault.

Se aplica a

FaultException<TDetail>(TDetail, FaultReason, FaultCode, String)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error de SOAP, el código y los valores de la acción.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, and SOAP fault reason, code and action values.

public:
 FaultException(TDetail detail, System::ServiceModel::FaultReason ^ reason, System::ServiceModel::FaultCode ^ code, System::String ^ action);
public FaultException (TDetail detail, System.ServiceModel.FaultReason reason, System.ServiceModel.FaultCode code, string action);
new System.ServiceModel.FaultException<'Detail> : 'Detail * System.ServiceModel.FaultReason * System.ServiceModel.FaultCode * string -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail, reason As FaultReason, code As FaultCode, action As String)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

reason
FaultReason

La razón del error de SOAP.The reason for the SOAP fault.

code
FaultCode

El código de error para el error de SOAP.The fault code for the SOAP fault.

action
String

La acción del error de SOAP.The action of the SOAP fault.

Se aplica a

FaultException<TDetail>(TDetail, String, FaultCode, String)

Inicializa una nueva instancia de la clase FaultException<TDetail> que utiliza el objeto de detalle especificado, la razón del error de SOAP, el código y los valores de la acción.Initializes a new instance of the FaultException<TDetail> class that uses the specified detail object, and SOAP fault reason, code and action values.

public:
 FaultException(TDetail detail, System::String ^ reason, System::ServiceModel::FaultCode ^ code, System::String ^ action);
public FaultException (TDetail detail, string reason, System.ServiceModel.FaultCode code, string action);
new System.ServiceModel.FaultException<'Detail> : 'Detail * string * System.ServiceModel.FaultCode * string -> System.ServiceModel.FaultException<'Detail>
Public Sub New (detail As TDetail, reason As String, code As FaultCode, action As String)

Parámetros

detail
TDetail

El objeto utilizado como detalle del error de SOAP.The object used as the SOAP fault detail.

reason
String

La razón del error de SOAP.The reason for the SOAP fault.

code
FaultCode

El código de error para el error de SOAP.The fault code for the SOAP fault.

action
String

La acción del error de SOAP.The action of the SOAP fault.

Se aplica a