Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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) :

VB
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 :
VB
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
        'load values from app.config file
        'Dim FocusDBName As String
        'FocusDBName = ConfigurationManager.AppSettings("FocusDBName").ToString
        'MessageBox.Show(FocusDBName)
        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 :
VB
Private Function registerClient() As Boolean
        Dim FTObj As InterfaceFTObj
        Dim tcpChannel As TcpChannel 'Made global becoz need to unregister at mdimain form close event.
        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 = InterfaceFTObj
            FTObj = CType(Activator.GetObject(GetType(IFTObj.InterfaceFTObj), "tcp://127.0.0.1:2999/FTObj"), InterfaceFTObj)
            'FTMain = Activator.GetObject(Type.GetType("FTMainObj.clsFTMain,FTMainObj"), "tcp://Localhost:2999/FTMain") '- Creates a proxy
            'FTMain = Activator.GetObject(Type.GetType("FTMainObj.clsFTMain,FTMainObj"), "tcp://192.168.55.254:2999/FTMain")
            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[^]
Posted
Updated 22-Jan-13 19:44pm
v2

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