Results 1 to 2 of 2

Thread: Attempted to create well-known object of type 'IFTObj.InterfaceFTObj'. Well-known obj

  1. #1
    tonydsouza1987 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2012
    Posts
    1
    Reputation
    0

    Unhappy Attempted to create well-known object of type 'IFTObj.InterfaceFTObj'. Well-known obj

    I have the following Projects :

    • IFTObj : Interface
    • 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) :

    Code:
    Imports System.Runtime.Remoting
    Imports System.Runtime.Remoting.Channels
    Imports System.Runtime.Remoting.Channels.Tcp
    Imports System.DataImports System.Data.SqlClient
    Imports IFTObjPublicClass clsFTObj    
    Inherits MarshalByRefObject    
    Implements IFTObj.InterfaceFTObj
    
    • FTHostServer : Hosting IFTObj. The code is as follows :

    Code:
    Imports System.Runtime.Remoting
    Imports System.Runtime.Remoting.Channels
    Imports System.Runtime.Remoting.Channels.Tcp
    Imports System.Configuration
    Imports IFTObj
    PublicClass MDIMain    
    Dim tcpChannel As TcpChannel    
    PrivateSub MDIMain_Load(ByVal sender AsObject,ByVal e As System.EventArgs)HandlesMe.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
    EndSub
    
    PrivateSub MDIMain_FormClosed(ByVal sender AsObject,ByVal e As System.Windows.Forms.FormClosedEventArgs)HandlesMe.FormClosed 
    ChannelServices.UnregisterChannel(tcpChannel)
    EndSubEndClass

    • FTClient : the code is as follows :

    Code:
    PrivateFunction 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.")ReturnFalseEndIfCatch 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.
    Problems hosting a remote interface
    Last edited by tonydsouza1987; 01-23-2013 at 4:19 AM.

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,080
    Reputation
    2802
    'Attempted to create well-known object of type 'IFTObj.InterfaceFTObj'. Well-known objects must derive from the MarshalByRefObject class'
    That means the type of the well-known object you want to register must inherit MarshalByRefObject. Interfaces can only inherit other interfaces so InterfaceFTObj type can't meet the requirement. Your class clsFTObj inherits MarshalByRefObject and would meet that requirement.

    About .NET Remoting now:
    This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •