Programmer's Highway

VB.NET Tips and simple code

I'm very sorry for machine translation in English.

VB.NET IPC Problem that is automatically disconnected

RemotingException: Requested Service not found.

If you are running a default configuration interprocess communication, will be disconnected automatically if there is no remote connection a certain period of time.
And, Exception below is thrown when you connect from the client.

Requested Service not found

To avoid this problem, we disable the lifetime of the instance by returning a null to override MarshalByRefObject InitializeLifetimeService of the remote object class. http://msdn.microsoft.com/library/en-us/system.marshalbyrefobject.initializelifetimeservice(v=vs.100).aspx

Namespace IpcSample
    Public Class IpcRemoteObject
        Inherits MarshalByRefObject
    
        Public Property Counter() As Integer
    
        ''' <summary>
        ''' To avoid disconnected automatically
        ''' </summary>
        Public Overrides Function InitializeLifetimeService() As Object
            Return Nothing
        End Function
    
    End Class
End Namespace
Visual Studio 2010 .NET Framework 4