Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:59:50+00:00 2026-05-24T16:59:50+00:00

I have a webservice being consumed in the WinForm application. I generated a web

  • 0

I have a webservice being consumed in the WinForm application. I generated a web service wrapper and invoked a web service method asynchronously. I get following exception in my result completed event handler (the event is raised from within the web service wrapper class). What could be the problem?

    System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.  Check InnerException for exception details. 
---> System.Net.WebException: Unable to connect to the remote server 
---> System.Net.Sockets.SocketException: A connect request was made on an already connected socket
       at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
       at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
       --- End of inner exception stack trace ---
       at System.Web.Services.Protocols.WebClientAsyncResult.WaitForResponse()
       at System.Web.Services.Protocols.WebClientProtocol.EndSend(IAsyncResult asyncResult, Object& internalAsyncState, Stream& responseStream)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.InvokeAsyncCallback(IAsyncResult result)
       --- End of inner exception stack trace ---
       at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()

Unfortunately I cannot put the complete wrapper code here. But this is the event args that i access (see Result property below)

<ComVisible(False), System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")> _
    Public Delegate Sub MyCompletedEventHandler(ByVal sender As Object, ByVal e As MyCompletedEventArgs)

<ComVisible(False), _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053"), _
     System.Diagnostics.DebuggerStepThroughAttribute(), _
     System.ComponentModel.DesignerCategoryAttribute("code")> _
    Partial Public Class MyCompletedEventArgs
        Inherits System.ComponentModel.AsyncCompletedEventArgs

        Private results() As Object

        Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object)
            MyBase.New(exception, cancelled, userState)
            Me.results = results
        End Sub

        '''<remarks/>
        Public ReadOnly Property Result() As MyResponse
            Get
                Me.RaiseExceptionIfNecessary()
                Return CType(Me.results(0), MyResponse)
            End Get
        End Property
    End Class

Private Sub OnMyOperationCompleted(ByVal arg As Object)
            If (Not (Me.MyCompletedEvent) Is Nothing) Then
                Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg, System.Web.Services.Protocols.InvokeCompletedEventArgs)
                RaiseEvent MyPointsCompleted(Me, New MyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState))
            End If
        End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:59:51+00:00Added an answer on May 24, 2026 at 4:59 pm

    I had a similar problem when I tried to reuse a socket instance multiple times. Even with socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);, it seems to be not reliable.

    I don’t use .NET web service wrapper, but you should perhaps looking for something like (implementation to adapt…):

    try 
    {
        // socket connection...
    }
    catch (SocketException ex)
    {
        if (ex.SocketErrorCode == SocketError.AddressAlreadyInUse) 
        {
            // retry with a new instance socket.
        }
    }
    

    Or simply create a new instance of the web service request before each call…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Help! I have an Axis web service that is being consumed by a C#
I'm seeing a very strange issue with a .NET webservice being consumed by Flex.
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know,
I have a .NET web service that returns XML, and I'd like to compress
I have a webservice that when called without specifying a callback will return a
I have a webservice that exists in an asp.net website. When I publish the
I have a webservice in java that receives a list of information to be
I have a webservice and client in c#/dotnet and I am using EnableDecompression to
I have a webservice (asmx file) in a directory requiring form authentication When I
I have a webservice that is called by up to 10 clients. The webservice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.