Eaglestorm26
New member
- Joined
- May 20, 2010
- Messages
- 3
- Programming Experience
- 1-3
Hello I am working on a simple Remoting example to get the basic understanding of it. However I am getting an error when creating the Remoteobject in the client that says "Tcp Channel protocol violation" was encountered. I was wondering what I have set up that would cause this below is the setup of my code.
'Code for the server page form.
'Code for the client page form
'code for the app.config in the bin/debug directory for the server host same directory as the exe
'code for the app.config in the bin/debug directory for the client same directory as the exe
The Remote Object class library dll. Both the client form project and server form project have references to the RemoteObject dll.
'Code for the server page form.
VB.NET:
Imports System.Runtime.Remoting
Public Class HostForm
Inherits System.Windows.Forms.Form
Private Sub HostForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Start listening for client requests, according to the
'information specified in the configuration file.
Try
RemotingConfiguration.Configure("SimpleServer.exe.config")
Catch ex As Exception
Dim err As String
err = ex.Message
MessageBox.Show("Error :" & err)
End Try
End Sub
End Class
'Code for the client page form
VB.NET:
Imports System.Runtime.Remoting
Public Class ClientForm
Private Sub ClientForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Configure the Client
RemotingConfiguration.Configure("SimpleClient.exe.config", False)
'Display the current domain.
MessageBox.Show("The Client application is executing in:" & AppDomain.CurrentDomain.FriendlyName)
Try
'Create the remote object, and determine what domain it is
'executing in. This line throws the error.
Dim RemoteObj As New RemoteObjects.RemoteObject
MessageBox.Show("The remote object is executing in: " & RemoteObj.GetActiveDomain)
Catch ex As Exception
Dim err As String
err = ex.Message
MessageBox.Show("Error :" & err)
End Try
End Sub
End Class
'code for the app.config in the bin/debug directory for the server host same directory as the exe
VB.NET:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application name="SimpleServer">
<service>
<activated type="RemoteObjects.RemoteObject, RemoteObjects" />
</service>
<channels>
<channel ref="tcp server" port="8080" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
'code for the app.config in the bin/debug directory for the client same directory as the exe
VB.NET:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application name="SimpleClient">
<client url="tcp://localhost:8080/SimpleServer">
<activated type="RemoteObjects.RemoteObject, RemoteObjects"/>
</client>
<channels>
<channel ref="tcp client"/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
The Remote Object class library dll. Both the client form project and server form project have references to the RemoteObject dll.
VB.NET:
Public Class RemoteObject
Inherits MarshalByRefObject
'Return the name of the current application domain.
Public Function GetActiveDomain() As String
Return AppDomain.CurrentDomain.FriendlyName
End Function
End Class