[Mono-list] Re moting Problem - Object reference not set to an instance

hematec c.heurich at hematec.de
Tue Nov 10 03:21:00 EST 2009


Hello,

i really urgent need some help!!
i'm trying to port a C# remotingproject over to mono.
The project uses a singleton SAO as a factory for the CAO (Client).

When i try to call a function (Client.AreUAlive()) at the Client i will get
a "Object reference not set error".
The curios is that this is working without any problem in C# (VS 2005).

I'm using Ubuntu 9.10 and Mono JIT 2.4.2.3 x86 in a VirtualBox environment.

Is this a bug in mono or do i miss something???

Many thanks in advance.

Structure:

I'm using TCP-Channel and binary formatters.
The SAO and CAO are exposed not directly but through Interfaces
(IRemotedClientFactory & IRemotedClientObject) defined in a shared DLL.
The Server holds the classes for the ClientFactory and the
RemotedClientObject (these are not shared to the client).
The client will get the clientobject by calling a function of the remoted
factory (this is because to avoid providing the clientobjects code to the
client-app).
The clientobject exposes the method and functions to the clients.


Source:

* Shared DLL *
***********
Public Interface IRemotedClientFactory
    Function Reachable() As Boolean
    Function GetClientObject(ByVal sDataSourceName As String, ByVal
sServerIP As String) As FactoryReturnObject
    Event NotifyEvent As FactoryNotificationEventHandler
End Interface

Public Interface IRemotedClientObject
    Function Execute(ByVal sCommand As String, ByVal oParams() As Object) As
Object
    Function AreUAlive() As Boolean
End Interface
...
<Serializable()> _
Public Class FactoryReturnObject
    Inherits MarshalByRefObject

    Public IsSuccess As Boolean = False
    Public ErrorID As Integer = -1
    Public ErrorMessage As String = ""
    Public ClientObject As IRemotedClientObject

    Public Sub New(ByVal oClientObject As IRemotedClientObject)
        IsSuccess = True
        ClientObject = oClientObject
    End Sub

    Public Sub New(ByVal iErrID As Integer, ByVal sErrMsg As String)
        IsSuccess = False
        ErrorID = iErrID
        ErrorMessage = sErrMsg
    End Sub
End Class


* Server *
********
public class RemotedClientFactory : MarshalByRefObject,
RemotePresenterDLL.IRemotedClientFactory
    {

        public RemotePresenterDLL.FactoryReturnObject GetClientObject(string
sClientID, string sServerIP)
        {
            // This is called by the client to get the clientobject
...
            // return object
            return new RemotePresenterDLL.FactoryReturnObject(new
RemotedClientObject(sClientIP, sClientID));
        }
...
    }


public class RemotedClientObject : MarshalByRefObject,
RemotePresenterDLL.IRemotedClientObject
    {
        public Boolean AreUAlive()
        {
            // This causes the error !!!
            return true;
        }
...
    }

* Client *
*******
// Vars
RemotePresenterDLL.IRemotedClientFactory  m_oFactory;
RemotePresenterDLL.IRemotedClientObject  m_oRemotedClient;
RemotePresenterDLL.FactoryReturnObject oFactRet;

private void Connect()
    {
...
    m_oFactory =
Activator.GetObject(typeof(RemotePresenterDLL.IRemotedClientFactory),
"<NameOfTCPChannel>") as RemotePresenterDLL.IRemotedClientFactory;
    oFactRet = m_oFactory.GetClientObject(<>,<>);
    m_oRemotedClient = oFactRet.ClientObject;
    oFactRet.ClientObject = null; // Needs to be set under Win because of
GarbColl in Server!!

    // This call causes the error !!
    bTmp = m_oRemotedClient.AreUAlive();
   }
-- 
View this message in context: http://old.nabble.com/Remoting-Problem---Object-reference-not-set-to-an-instance-tp26253784p26253784.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list