Handle exceptions in .net remoting objects
I am working on a .Net Remoting project. If there is any exception in remote object, I would like to send that exception in detail to the client. I am using the following code to accomplish that-
'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? Did i miss something else? Please help me.
Thanks in advance SKPaul
You've got it right there - the exception you'll catch is a RemotingException. I've always preferred WCF to remoting, but it appears you've set things up correctly in your example.
Are you getting a particular problem, or it something not working correctly, or are you just asking out of curiosity as you're setting setting things up?
精彩评论