I have the following Projects :
IFTObj : Interface DLL.
FTObj : Remote object hosted in EXE. This objects inherits MarshalByRefObject and implements the IFTObj interface. In this Object I have two classes 'clsFTObj' and 'clsSQLDBWrapper'. Class 'clsFTObj' inherits MarshalByRefObject. Class 'clsSQLDBWrapper' does not inherits MarshalByRefObject, even though i tried inheriting or making it serilizable after getting the error. The little code of this object is as follows(all the methods are implemeted here) :
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Data
Imports System.Data.SqlClient
Imports IFTObj
Public Class clsFTObj
Inherits MarshalByRefObject
Implements IFTObj.InterfaceFTObj
FTHostServer : Hosting IFTObj. The code is as follows :
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Configuration
Imports IFTObj
Public Class MDIMain
Dim tcpChannel As TcpChannel
Private Sub MDIMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off
Dim props As IDictionary = New Hashtable
props("port") = "2999"
props("name") = "FTObj"
Dim servProvider As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider
Dim clientProvider As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider
servProvider.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full
tcpChannel = New TcpChannel(props, clientProvider, servProvider)
ChannelServices.RegisterChannel(tcpChannel, False)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(IFTObj.InterfaceFTObj), "FTObj", WellKnownObjectMode.SingleCall)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub MDIMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
ChannelServices.UnregisterChannel(tcpChannel)
End Sub
End Class
FTClient : the code is as follows :
Private Function registerClient() As Boolean
Dim FTObj As InterfaceFTObj
Dim tcpChannel As TcpChannel
Try
Dim servProvider As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider
Dim clientProvider As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider
servProvider.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full
Dim props As IDictionary = New Hashtable
props("port") = 0
tcpChannel = New TcpChannel(props, clientProvider, servProvider)
ChannelServices.RegisterChannel(tcpChannel, False)
FTObj = CType(Activator.GetObject(GetType(IFTObj.InterfaceFTObj), "tcp://127.0.0.1:2999/FTObj"), InterfaceFTObj)
If FTObj Is Nothing Then
MessageBox.Show("Server does not exist, Please make sure you are connected to internet or contact administrator.")
Return False
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return True
End Function
The server runs fine and the client also registers fine. When the method is called of the remote object (FTObj) via interface on client, I get the below error :
'Attempted to create well-known object of type 'IFTObj.InterfaceFTObj'. Well-known objects must derive from the MarshalByRefObject class'
I have copied the FTObj, IFTObj in the FTHostServer Debug folder and tried, the same. Does that has to do something with another class in FTObj??? The methods of class 'clsSQLDBWrapper' are accessed in 'clsFTObj' class. Helping me in solving the error would be appreciated. I didnt found any help on this error online, even in the below link(which shows exactly my problem) which is still unanswered.
http://social.msdn.microsoft.com/Forums/eu/netfxremoting/thread/1ec8e70d-c49e-4df2-9920-30a1ac290e6e[
^]