x86 compiled has errors with 64 bit computers, but only when in .exe RRS feed

  • Question

  • So, i'm using VS2010 and .Net 2003.

    I'm distributing my program to other people by giving them the .exe found in the Bin folder. It's compiled as x86 and is in Debug.

    Those with 64-bit computers encounter this error sometimes "Argument "Length" must be Greater or Equal to Zero."

    However, when i use the Solution and test it on a 64 bit computer, even in x86 compilation mode (set in Debug and Release), there are no errors.

    EDIT: Please see Post #3 for more detail.

    Any suggestions? Thanks.

    • Edited by seattleite Thursday, July 14, 2011 6:53 AM
    • Moved by Paul Zhou Tuesday, August 2, 2011 9:54 AM (From:64-Bit .NET Framework Development.)
    Tuesday, July 12, 2011 4:40 AM

All replies

  • Try compiling it in 'Any CPU' mode. That should solve your problem.
    Tuesday, July 12, 2011 10:23 AM
  • I would, but that means I would lose my WMP control, and there is only a 32-bit version of it in existance :(


    EDIT: I replaced the part with Mid and substituted something else... but I still have the error of Argument Length in another part of my code. Here's my code:


    Pathy = ""
         DABytes = InetConnection(Pathy)
         Pathy = ""
         bytes = InetConnection(Pathy)
         TempTargetFolder = ByteArrayToString(bytes)
         Targetfolder = Application.StartupPath & TempTargetFolder
         ErrorMessage = "Cannot make a new .exe file. Try running this program as an administrator, and make sure this Folder is not locked."
         foldera = FreeFile()
          FileOpen(foldera, Targetfolder, OpenMode.Binary)
          FilePut(foldera, DABytes)
          System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
          MsgBox("Download successful! This program will now close." & vbCrLf & vbCrLf & "You are free to delete the older version in your LCCG folder.")
         Catch ex As Exception
          System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
         End Try<br/><br/>


    Here is the "InetConnection" Function, which returns a Byte Array:



    Public Function InetConnection(ByVal SomePath As String) As Byte()<br/>Dim Inet1 As System.Net.WebRequest = _
       DirectCast(System.Net.HttpWebRequest.Create(SomePath), _
      Dim resp As System.Net.WebResponse = Nothing
       resp = Inet1.GetResponse()
       Dim br As New IO.BinaryReader(resp.GetResponseStream())
       InetConnection = br.ReadBytes(CInt(resp.ContentLength))
       InetException = False
      Catch ex As System.Net.WebException
       InetException = True
      End Try<br/>end function


    Thursday, July 14, 2011 1:12 AM
  • Hi,

    Which code part threw this exception?

    It seems that the issue is related to Network response. I suggest you post thread in  Network Class Library (System.Net) forum.

    Have a nice day.

    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 14, 2011 7:58 AM