DomainOperationException Class

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Indicates that at least one error has occurred during the processing of the domain operations on the server.

Inheritance Hierarchy

System.Object
System.Exception
System.ServiceModel.DomainServices.Client.DomainOperationException

Namespace: System.ServiceModel.DomainServices.Client
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

Syntax

'Declaration
Public NotInheritable Class DomainOperationException _
    Inherits Exception
'Usage
Dim instance As DomainOperationException
public sealed class DomainOperationException : Exception
public ref class DomainOperationException sealed : public Exception
[<SealedAttribute>]
type DomainOperationException =  
    class
        inherit Exception
    end
public final class DomainOperationException extends Exception

The DomainOperationException type exposes the following members.

Constructors

Name Description
Public method DomainOperationException() Initializes a new instance of the DomainOperationException class.
Public method DomainOperationException(String) Initializes a new instance of the DomainOperationException class with a specified message that describes the error.
Public method DomainOperationException(String, Exception) Initializes a new instance of the DomainOperationException class with a specified error message and a reference to the inner exception that is the cause of this exception.
Public method DomainOperationException(String, OperationErrorStatus) Initializes a new instance of the DomainOperationException class with a localized exception message and status.
Public method DomainOperationException(String, OperationErrorStatus, Int32) Initializes a new instance of the DomainOperationException class with a localized exception message, status and custom error code.
Public method DomainOperationException(String, OperationErrorStatus, Int32, String) Initializes a new instance of the DomainOperationException class with optional localized message, status, custom error code, and stack trace of the exception.

Top

Properties

Name Description
Public property Data (Inherited from Exception.)
Public property ErrorCode Gets or sets the custom error code for this exception. The error code can be any user-defined value.
Public property HelpLink (Inherited from Exception.)
Protected property HResult (Inherited from Exception.)
Public property InnerException (Inherited from Exception.)
Public property Message (Inherited from Exception.)
Public property Source (Inherited from Exception.)
Public property StackTrace Gets the stack trace of the exception. (Overrides Exception.StackTrace.)
Public property Status Gets or sets the status code for this exception.
Public property TargetSite (Inherited from Exception.)

Top

Methods

Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetBaseException (Inherited from Exception.)
Public method GetHashCode (Inherited from Object.)
Public method GetObjectData (Inherited from Exception.)
Public method GetType (Inherited from Exception.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Exception.)

Top

Examples

Partial Public Class MainPage
    Inherits UserControl

    ' Create a CustomerDomainContext for the CustomerDomainService
    Private _customerContext As CustomerDomainContext

    Public Function MainPage()
        InitializeComponent()

        ' Create an EntityQuery of type Customer
        Dim query As EntityQuery(Of Customer) = _
            From c In _customerContext.GetCustomersQuery() _
            Where (c.Phone.StartsWith("583")())() _
            Order By (c.LastName) _
            Select c()

        ' Create and execute a LoadOperation of type Customer and load 'query'
        Dim loadOp As LoadOperation = Me._customerContext.Load(query)

        ' Create a new DomainOperationException for a Validation Error
        Dim opEx As DomainOperationException = New DomainOperationException( _
                                                "Validation Error", _
                                                OperationErrorStatus.ValidationError, _
                                                9466)
        ' Check if there are any ValidationErrors when loadOp was executed
        ' Then throw the DomainOperationException opEx
        If loadOp.ValidationErrors <> Empty Then
            Throw opEx
        End If

        ' Populate the CustomerGrid with the Entities in loadOp
        CustomerGrid.ItemsSource = loadOp.Entities

    End Function

End Class
public partial class MainPage : UserControl
{
        // Create a CustomerDomainContext for the CustomerDomainService
        private CustomerDomainContext _customerContext = new CustomerDomainContext();

        public MainPage()
        {
            InitializeComponent();

            // Create an EntityQuery of type Customer
            EntityQuery<Customer> query =
                from c in _customerContext.GetCustomersQuery()
                where c.Phone.StartsWith("583")
                orderby c.LastName
                select c;

            // Create and execute a LoadOperation of type Customer and load 'query'
            LoadOperation<Customer> loadOp = this._customerContext.Load(query);

            // Create a new DomainOperationException for a Validation Error
            DomainOperationException opEx = new DomainOperationException(
                "Validation Error",
                OperationErrorStatus.ValidationFailed,
                0x000024FA);

            // Check if there are any ValidationErrors when loadOp was executed
            // Then throw the DomainOperationException opEx
            if (loadOp.ValidationErrors != null)
            {
                throw opEx;
            }

            // Populate the CustomerGrid with the Entities in loadOp
            CustomerGrid.ItemsSource = loadOp.Entities;
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.ServiceModel.DomainServices.Client Namespace