Remote Server Side Interface:
Remoting Server side code:Code:Public Interface IRemotingServer Function GetNewCOMObj() As VB6ComServer.ActiveX-EXE.ClassVB6ComServer End Interface
Remoting Server Remoting code:Code:Imports VB6ComServer.ActiveX-EXE 'ActiveX Exe COM Server Public Class RemotingServer Inherits MarshalByRefObject Implements IRemotingServer Public mgr As VB6ComServer.ActiveX-EXE.ClassVB6ComServer Function GetNewCOMObj() As VB6ComServer.ActiveX-EXE.ClassVB6ComServer Implements IRemotingServer.GetNewCOMObj Dim mgr As New VB6ComServer.ActiveX-EXE.ClassVB6ComServer Return mgr End Class
Remoting Client Side Code:Code:Dim ServiceChannel As IChannel Dim serverProv As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider Dim clientProv As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider Dim Props As IDictionary = New Hashtable Dim IpInjProvider As New IpInjectorSinkProvider serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full Props("port") = "8000" Props("name") = "RemoteServer.rem" serverProv.Next = IpInjProvider ServiceChannel = New TcpChannel(Props, clientProv, serverProv) '--------------------------------------------- ChannelServices.RegisterChannel(ServiceChannel) RemotingConfiguration.RegisterWellKnownServiceType( _ GetType(VB6ComServer.ActiveX-EXE.ClassVB6ComServer), _ "RemoteServer.rem", WellKnownObjectMode.Singleton)
COM Client Code:Code:Imports System.Runtime.InteropServices Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels Imports System.Runtime.Remoting.Channels.Tcp Imports System.Net Imports System.ServiceModel Imports System.Configuration <Guid("6CC8BE47-2552-4832-8924-21C67A5EAFEB"), _ InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _ Public Interface _clsManager_Client <DispId(1)> Function GetMonth() As Integer <DispId(2)> Function GetDay() As Integer <DispId(3)> Function GetYear() As Integer <DispId(4)> Function GetNewManager() As VB6ComServer.ActiveX-EXE.ClassVB6ComServer End Interface <Guid("3d9e2e6f-5bf2-f14f-879b-4e5b0af104e9"), _ ClassInterface(ClassInterfaceType.AutoDual), _ ProgId("comDemo.demo")> _ Public Class clsManager_Client Implements _clsManager_Client Public Function GetMonth() As Integer Implements _clsManager_Client.GetMonth GetMonth = DateTime.Now.Month End Function Public Function GetDay() As Integer Implements _clsManager_Client.GetDay GetDay = DateTime.Now.Day End Function Public Function GetYear() As Integer Implements _clsManager_Client.GetYear GetYear = DateTime.Now.Year End Function Public obj As New clsPrivateManager Public Function GetNewManager() As VB6ComServer.ActiveX-EXE.ClassVB6ComServer Implements _clsManager_Client.GetNewManager Dim thing As IRemotingServer thing = obj.CreateProxyInstance Dim mgr As VB6ComServer.ActiveX-EXE.ClassVB6ComServer mgr = thing.GetNewManager MsgBox("getting manager") Return mgr End Function Public Sub New() MyBase.New() End Sub Public Enum CommunicationPlatform Remoting End Enum Public defaultPlatform As CommunicationPlatform Public ReadOnly Property Platform As CommunicationPlatform Get Return defaultPlatform End Get End Property Public factory As ChannelFactory(Of IRemotingServer) = Nothing Public Sub ClientProxyFactory() RemotingConfiguration.Configure("app.config", False) defaultPlatform = [Enum].Parse(GetType(CommunicationPlatform), _ ConfigurationManager.AppSettings("communicationPlatform")) End Sub Public Function CreateProxyInstance() As IRemotingServer Return CreateProxyInstance(defaultPlatform) End Function Public Function CreateProxyInstance(platform As CommunicationPlatform) As IRemotingServer Dim proxy As IRemotingServer proxy = Nothing Select Case platform Case CommunicationPlatform.Remoting proxy = CType(Activator.GetObject(GetType(IRemotingServer), "tcp://localhost:8000/RemoteServer.rem"), IRemotingServer) End Select Return proxy End Function Private chan As TcpChannel Public mgr As IRemotingServer Private varIdling As Integer Public Property Idling As Integer Get Return varIdling End Get Set(value As Integer) varIdling = value End Set End Property Public Sub New() MyBase.New() On Error Resume Next Idling = 15 End Sub End Class
Code:Private mgr As VB6ComServer.ActiveX-EXE.ClassVB6ComServer Private mgrs As New RemotingClient.clsManager_Client Private Sub CreateManager() Dim i As Integer 'Dim mgr As New cVB6ComServer.ActiveX-EXE.ClassVB6ComServer i = mgrs.GetDay ' <-- THESE WORK i = mgrs.GetMonth i = mgrs.GetYear mgr = mgrs.GetNewManager ' <-- THIS DOESN'T WORK. I get E_NOINTERFACE End Sub




Reply With Quote
