Results 1 to 14 of 14

Thread: {"An invalid argument was supplied"}

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    {"An invalid argument was supplied"}

    Hello everyone. I have to make changes to my project, but I can't even test my code because I get an error.

    The error is this...

    System.Net.Sockets.SocketException - An invalid argument was supplied


    Hopefully the messages shown in the image below will make some sense.

    I assume it's a .Net issue, but I am not experiencing any issues with .Net
    Attached Images Attached Images  
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: {"An invalid argument was supplied"}

    Are you using sockets? Are they in a class instance, or part of a form? If they are a class instance, is an instance created on startup, or is the first instance created in code at a later time? I would guess that you are creating an instance with a line like this:

    Private mySocket = New MySocketContainingClass

    form level variables on the startup form, or similar global variables in a module, will be created before the program officially starts, which makes them interesting to debug.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    I haven't changed anything from the working version and this version. I opened my project and now I get this issue.

    Two weeks ago I was able to run this just fine, without any changes.

    I use Microsofts FTP WebRequest and FTP WebResponse classes.

    vb Code:
    1. Private Shared _ftp As FtpWebRequest
    2.     Private Shared _ftpResponse As FtpWebResponse


    I use that with a URI builder.

    Because I'm getting this error message, I believe it's got something to do with .Net framework.


    Take a look at the call stack location in the image below.
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: {"An invalid argument was supplied"}

    Actually, I'm not all that surprised by it suddenly happening, though I wouldn't be too quick to blame the framework. The thing is that you are dealing with a network. Those shared variables could certainly cause issues, though not from the code you just posted. All that does is declare the variables, it doesn't create the instances. When do you create the instances? Does that happen in an exception handler?

    What I am thinking is that they are failing as they are being created due to some issue with the network, itself, having changed some. That could be an internal error, but it is pretty unlikely. More likely, if you could narrow it down, you'd be able to figure it out. Therefore, I'd be taking a look at where the shared objects are being created, and the code around them.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    Ok, so this is how I declare my FTPWebRequest and Reponse.

    vb.net Code:
    1. Private Shared _ftp As FtpWebRequest
    2.     Private Shared _ftpResponse As FtpWebResponse
    3.     Private Shared _builderURI As UriBuilder = New UriBuilder
    4.     Private Shared _ftpURI As Uri
    5.     Private Shared _username As String
    6.     Private Shared _password As String
    7.     Private Shared _hostname As String = "ww2.hostname.com"
    8.  
    9.     Public Shared Property ftpRequest() As FtpWebRequest
    10.         Get
    11.             Return _ftp
    12.         End Get
    13.         Set(ByVal value As FtpWebRequest)
    14.             _ftp = value
    15.         End Set
    16.     End Property
    17.  
    18.     Public Shared Property ftpResponse() As FtpWebResponse
    19.         Get
    20.             Return _ftpResponse
    21.         End Get
    22.         Set(ByVal value As FtpWebResponse)
    23.             _ftpResponse = value
    24.         End Set
    25.     End Property
    26.  
    27.     Public Shared Property builderURI() As UriBuilder
    28.         Get
    29.             Return _builderURI
    30.         End Get
    31.         Set(ByVal value As UriBuilder)
    32.             _builderURI = value
    33.         End Set
    34.     End Property
    35.  
    36.     Public Shared Property ftpURI() As Uri
    37.         Get
    38.             Return _ftpURI
    39.         End Get
    40.         Set(ByVal value As Uri)
    41.             _ftpURI = value
    42.         End Set
    43.     End Property
    44.  
    45.     Public Shared Property Username() As String
    46.         Get
    47.             Return _username
    48.         End Get
    49.         Set(ByVal value As String)
    50.             _username = value
    51.         End Set
    52.     End Property
    53.  
    54.     Public Shared Property Password() As String
    55.         Get
    56.             Return _password
    57.         End Get
    58.         Set(ByVal value As String)
    59.             _password = value
    60.         End Set
    61.     End Property
    62.  
    63.     Public Shared Property Hostname() As String
    64.         Get
    65.             Return _hostname
    66.         End Get
    67.         Set(ByVal value As String)
    68.             _hostname = value
    69.         End Set
    70.     End Property
    71.  
    72.     Public Shared Property Method() As String
    73.         Get
    74.             Return _method
    75.         End Get
    76.         Set(ByVal value As String)
    77.             If Not ftpRequest Is Nothing Then
    78.                 ftpRequest.Method = value
    79.             End If
    80.             _method = value
    81.         End Set
    82.     End Property
    83.  
    84.  
    85.     Public Shared Sub BuildURI()
    86.         Try
    87.  
    88.             WriteToEventLog("Building URI....")
    89.             builderURI.Host = Hostname
    90.             builderURI.Password = Password
    91.             builderURI.UserName = Username
    92.  
    93.             builderURI.Port = 21
    94.             ' builderURI.Path = "testing/" 'TODO: REMOVE after testing
    95.             builderURI.Scheme = Uri.UriSchemeFtp
    96.             Debug.Print(builderURI.Uri.ToString)
    97.             ftpURI = builderURI.Uri
    98.             WriteToEventLog("Building URI Completed!")
    99.  
    100.         Catch ex As Exception
    101.             Debug.Print(ex.Message)
    102.             WriteToEventLog(ex)
    103.         End Try
    104.  
    105.     End Sub
    106.  
    107.     ''' <summary>
    108.     ''' This will create the FtpWebRequest and then set the request method to the method defined.
    109.     ''' </summary>
    110.     ''' <remarks>This must be called after BuildURI</remarks>
    111.     Public Shared Sub CreateRequest()
    112.         Try
    113.  
    114.             ftpRequest = FtpWebRequest.Create(ftpURI)
    115.  
    116.             'ftpRequest.Method = Method
    117.         Catch ex As Exception
    118.  
    119.             WriteToEventLog(ex)
    120.  
    121.         End Try
    122.  
    123.     End Sub
    124.  
    125.     ''' <summary>
    126.     ''' Get the StatusDescription from the last method requested. IE: get the returned Status Code/Description.
    127.     ''' </summary>
    128.     ''' <remarks>Call this after every request.</remarks>
    129.     Public Shared Function GetServerStatus()
    130.  
    131.         Try
    132.  
    133.             ftpResponse = ftpRequest.GetResponse()
    134.             RaiseEvent OnFtpStatusChanged(Nothing, New FtpStatusChangedEventArgs(ftpResponse.StatusDescription)) 'response))
    135.             Dim response As String = Strings.Right(ftpResponse.StatusDescription, ftpResponse.StatusDescription.Length - 4)
    136.  
    137.             'WriteToEventLog("Server Status = " & response)
    138.             _serverStatus = response
    139.             Return response
    140.  
    141.         Catch ex As Exception
    142.  
    143.             WriteToEventLog(ex)
    144.             Return Nothing
    145.  
    146.         End Try
    147.  
    148.     End Function
    Last edited by TheUsed; Oct 25th, 2011 at 11:59 AM.
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    The above reponse hopefully helps.
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    I changed my network settings so that I only have one network adapter enabled and is the main adapter, and I get the same issue. (I made some changes to my network adapters for my virtual machines.)
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: {"An invalid argument was supplied"}

    Not much there that looks like it could be related. I take it you aren't getting any items popping up in your event log?

    Still, from the looks of it, you have exhausted that line of reasoning. Would I be correct in assuming that you aren't using any sockets directly, only whatever is being used for the FTP communication?
    My usual boring signature: Nothing

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    Quote Originally Posted by Shaggy Hiker View Post
    Not much there that looks like it could be related. I take it you aren't getting any items popping up in your event log?

    Still, from the looks of it, you have exhausted that line of reasoning. Would I be correct in assuming that you aren't using any sockets directly, only whatever is being used for the FTP communication?
    My event log does not show anything related to this issue. (just information events that show service start and stop times)

    You are correct that I am not using sockets directly. I am only using FtpWebRequest and FtpWebResponse that pertain to the .net framework.

    Im at a loss, I know that this error happening is going to withhold the ability to update the program as requested by my supervisor.

    I may just reinstall the framework(altho i've tried, Windows 7 is a stubborn pain in the ass when it comes to doing this.)
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    I have re-installed .net framework 4.0 and re-installed VS2010.

    The error is still there.

    What could cause an error as seen above?

    This was all working without making any changes, it then stopped working.
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    now ANOTHER project is experiencing the same issue. This program doesn't even use sockets, unless using Datasets requires sockets
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    Here is another image with more information that might help a more knowledged individual to help me.
    Attached Images Attached Images  
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: {"An invalid argument was supplied"}

    Ok I've uninstalled everything, that is VS2010 related and reinstalled. After re-installing the same issue happened where it would throw the invalid argument error. I have come to find out that I moved my project files from one file server to a different file server. The original file server was Windows Server 2003 while the new server is Windows Server 2008. The issue is that VS2010 does not like to open projects on a net share, this is causing the error to be thrown. I dont know the specifics of it yet, but this is what I found when I copied the projects to my desktop and ran them successfully from there. I moved them back to the shared drive and ran into the same issue.

    Has anyone ever experienced this before?
    RATE THOSE WHO ARE HELPFUL PLEASE!!

  14. #14
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: {"An invalid argument was supplied"}

    Yeah, I've run into issues opening projects on a network share. In my case, the problem wasn't worth studying, so I can't say anything more about it. I just moved the project local, which is where it kind of made sense, in my case.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width