DomainException 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 an unrecoverable error has occurred during the execution of a domain operation.
Inheritance Hierarchy
System.Object
System.Exception
System.ServiceModel.DomainServices.Server.DomainException
Namespace: System.ServiceModel.DomainServices.Server
Assembly: System.ServiceModel.DomainServices.Server (in System.ServiceModel.DomainServices.Server.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public NotInheritable Class DomainException _
Inherits Exception
'Usage
Dim instance As DomainException
[SerializableAttribute]
public sealed class DomainException : Exception
[SerializableAttribute]
public ref class DomainException sealed : public Exception
[<SealedAttribute>]
[<SerializableAttribute>]
type DomainException =
class
inherit Exception
end
public final class DomainException extends Exception
The DomainException type exposes the following members.
Constructors
Name | Description | |
---|---|---|
DomainException() | Initializes a new instance of the DomainException class with a system-supplied message that describes the error. | |
DomainException(String) | Initializes a new instance of the DomainException class with a specified message that describes the error. | |
DomainException(String, Exception) | Initializes a new instance of the DomainException class with a specified error message and a reference to the inner exception that is the cause of this exception. | |
DomainException(String, Int32) | Initializes a new instance of the DomainException class that has the specified error message and a custom error code. | |
DomainException(String, Int32, Exception) | Initializes a new instance of the DomainException class that has the specified error message, a custom error code, and the inner exception that is the cause of this exception. |
Top
Properties
Name | Description | |
---|---|---|
Data | (Inherited from Exception.) | |
ErrorCode | Gets or sets the custom error code for this exception. | |
HelpLink | (Inherited from Exception.) | |
HResult | (Inherited from Exception.) | |
InnerException | (Inherited from Exception.) | |
Message | (Inherited from Exception.) | |
Source | (Inherited from Exception.) | |
StackTrace | (Inherited from Exception.) | |
TargetSite | (Inherited from Exception.) |
Top
Methods
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
GetBaseException | (Inherited from Exception.) | |
GetHashCode | (Inherited from Object.) | |
GetObjectData | (Inherited from Exception.) | |
GetType | (Inherited from Exception.) | |
MemberwiseClone | (Inherited from Object.) | |
ToString | (Inherited from Exception.) |
Top
Remarks
Use this class to define the exception.
Examples
Partial Public Class MainPage
Inherits UserControl
' Create a CustomerDomainContext for the CustomerDomainService
Private _customerContext As CustomerDomainContext
Private domainException As DomainException = New DomainException("Error Message", 326)
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.Error <> Empty Then
Throw domainException
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();
// Create a new Custom DomainException
private DomainException domainException = new DomainException("Error Message", 0x00000326);
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.Error != null)
{
throw domainException;
}
// 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.