Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, June 22, 2013 7:01 AM
Remoting configuration failed with the exception 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. > System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start(Int32 backlog)
at System.Net.Sockets.TcpListener.Start()
at System.Runtime.Remoting.Channels.ExclusiveTcpListener.Start(Boolean exclusiveAddressUse)
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.StartListening(Object data)
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.SetupChannel()
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider, IAuthorizeRemotingConnection authorizeCallback)
at System.Runtime.Remoting.Channels.Tcp.TcpChannel..ctor(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
End of inner exception stack trace
at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Runtime.Remoting.RemotingConfigHandler.CreateChannelFromConfigEntry(ChannelEntry entry)
at System.Runtime.Remoting.RemotingConfigHandler.ConfigureChannels(RemotingXmlConfigFileData configData, Boolean ensureSecurity)
at System.Runtime.Remoting.RemotingConfigHandler.ConfigureRemoting(RemotingXmlConfigFileData configData, Boolean ensureSecurity)'.
our VB app's throws error while checking above mentioned error log written in eventlog file...
For more information, see Help and Support Center at
MANU
All replies (2)
Saturday, June 22, 2013 7:35 AM
Maybe when your tcplistener disconnects it then reconnects too quickly not allowing the logical port it uses in the IP stack to reset or something.
Although I don't remember seeing that issue with my code below though maybe it did occur and I didn't notice the error in the RichTextBox or perhaps I added the System.Threading.Thread.Sleep code before the Button1.PerformClick entry because it was happening. I don't remember now.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim ipAddress As IPAddress = ipAddress.Parse(TextBox1.Text)
Dim portNumber As Integer = TextBox2.Text
Dim tcpListener As New TcpListener(ipAddress, portNumber)
tcpListener.Start()
RichTextBox1.AppendText("Waiting for connection..." & vbCrLf)
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
RichTextBox1.AppendText("Connection accepted." & vbCrLf)
Dim FileSizeAndName As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
FileSizeAndName.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
Dim Split() As String
Dim delimiterStr As String = "/"
Dim delimiter As Char() = delimiterStr.ToCharArray()
Split = clientdata.Split(delimiter, 3)
Dim File As NetworkStream = tcpClient.GetStream()
Dim FileLength(CInt(Split(0) - 1)) As Byte
File.Read(FileLength, 0, CInt(Split(0) - 1))
My.Computer.FileSystem.WriteAllBytes(TextBox3.Text & "\" & Split(1), FileLength, False)
Label6.Text = TextBox3.Text & "\" & Split(1)
Dim responseString As String = "Connected to server."
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
File.Write(sendBytes, 0, sendBytes.Length)
RichTextBox1.AppendText(vbCrLf & "Message Sent /> : " & responseString)
tcpClient.Close()
tcpListener.Stop()
RichTextBox1.AppendText("exit")
Catch ex As Exception
RichTextBox1.AppendText(ex.Message)
End Try
System.Threading.Thread.Sleep(200)
Button1.PerformClick()
End Sub
You've taught me everything I know but not everything you know. _________________________________________________________________________________________________________________ This search engine is for MSDN Library and has many features. http://social.msdn.microsoft.com/Search/en-US?query=search%20msdn%20library&beta=0&ac=8
Thursday, November 5, 2015 11:35 PM
Most probable culprit to be the config file . Can you replace your previous config file and check if error appears?
ponnu