Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I am working on a .Net Remoting project. If there is any exception in remote object, I would like to send this exception in detail to the client. I am using the following code to accomplish that-
VB
'This is on a shared .dll
Public Interface ICreateNewMouza
    Function CreateNewMouza(ByVal MouzaToCreate As Mouza) As Integer
End Interface

Imports System
Imports System.Runtime.Serialization

<serializable()> _
Public Class CustomException
    Inherits System.ApplicationException

    Public Sub New(ByVal message As String)
        MyBase.New(message)
    End Sub

    Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
        MyBase.New(info, context)
    End Sub

    Public Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
        MyBase.GetObjectData(info, context)
    End Sub
End Class

'This is remote object which a client will invoke-

Imports System.Runtime.Remoting
Imports ClassInterfaces

Public Class CreateNewMouza
    Inherits MarshalByRefObject
    Implements ClassInterfaces.ICreateNewMouza

    Public Function CreateNewMouza(ByVal MouzaToCreate As ClassInterfaces.Mouza) As Integer Implements ClassInterfaces.ICreateNewMouza.CreateNewMouza
        Try
           ' some code
        Catch ex As Exception
          ## what should be here?
        End Try

    End Function
End Class



What should be in the try.. catch block?
Please help me.

Thanks in advance
SKPaul
Posted
Updated 20-Aug-11 2:38am
v2

1 solution

If you are using WCF services, then
[FaultContract] 
is the best solution for your requirement.

If itz just a web service, you can return the exception code from the server side. Client code can interpret to show the appropriate user message.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900