我正在开发一个.Net Remoting项目。如果远程对象中有任何异常,我想将该异常详细发送给客户端。我使用以下代码来完成 -
'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
try .. catch块应该是什么?我错过了别的什么吗? 请帮帮我。
提前致谢 SKPaul
答案 0 :(得分:0)
你已经把它弄好了 - 你会遇到的例外是RemotingException。我总是喜欢WCF进行远程处理,但看起来你已经在你的例子中正确设置了。
你是否遇到了一个特定的问题,或者是一些无法正常工作的问题,或者你只是在设置问题时出于好奇而问?