By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

VB.Net app not working on 32 bit machines

P: 142
I have an app that is a long time in the making and has had a lot of excellent input from others on. It runs great on 64 bit machines, but breaks down on any of the 32 machines I've run it on.

The app is designed to log on to the OpenDNS website, and then pull the history of URL visits from my router. It then dumps this to a CSV file, then saves it to Excel after sorting and removing fluff.

Because testing this requires an OpenDNS account, it may be hard for you all to test. But I'm hoping someone can look at the code, and see if they see anything that would be different for 64 bit vs 32 bit machines.

It appears to get through the first call to GetUrlData (data = GetUrlData(URL & "/signin", "GET", "")), but then doesn't come up with any data on the second call (data = GetUrlData(URL & "/signin", "POST", "formtoken=" & token & "&username=" & strUser & "&password=" & strPW & "&sign_in_submit=foo")). Therefore, I get the message "Please check your username and password.").

Here is the main sub...

Expand|Select|Wrap|Line Numbers
  1.     Private Sub btnFetch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFetch.Click
  3.         My.Settings.Save()
  5.         btnFetch.Text = "Processing"
  6.         Dim strUser As String = txtUser.Text
  7.         Dim strNet As String = txtNetwork.Text
  8.         Dim strBDate As String = txtBDate.Text
  9.         Dim strEDate As String = txtEDate.Text
  10.         Dim strPW As String = RC4(txtPW.Text, strK)
  11.         Dim DateRange As String = strBDate & "to" & strEDate
  12.         Dim page As Integer = 1
  13.         Dim objWriter As New System.IO.StreamWriter(CurPath & "DNLD.csv", False)
  14.         Dim i As Integer = 1
  16.         data = GetUrlData(URL & "/signin", "GET", "")
  18.         MsgBox(i)
  19.         i = i + 1
  21.         Dim Matches As Match = Regex.Match(data, ".*name=""formtoken"" value=""([0-9a-f]*)"".*")
  22.         Dim token As String = Matches.Value.Substring(Matches.Value.IndexOf("formtoken") + 18)
  23.         token = token.Substring(0, token.IndexOf(Chr(34)))
  25.         data = GetUrlData(URL & "/signin", "POST", "formtoken=" & token & "&username=" & strUser & "&password=" & strPW & "&sign_in_submit=foo")
  27.         MsgBox(i)
  28.         i = i + 1
  30.         If Len(data) <> 0 Then
  31.             MsgBox("Please check your username and password.")
  32.             Me.btnFetch.Text = Nothing
  33.             Exit Sub
  34.         End If
  36.         Do While True
  37.             data = GetUrlData(URL & "/stats/" & strNet & "/topdomains/" & DateRange & "/page" & page & ".csv", "GET", "")
  39.             MsgBox(i)
  41.             If page = 1 Then
  42.                 If Len(data) = 0 Then
  43.                     MsgBox("Please check your network." & strNet & vbCrLf)
  44.                     Me.btnFetch.Text = Nothing
  45.                     Exit Sub
  46.                 ElseIf InStr(data, "<!DOCTYPE") Then
  47.                     MsgBox("Error retrieving data. Date range may be outside of available data.")
  48.                     Me.btnFetch.Text = Nothing
  49.                     Exit Sub
  50.                 End If
  51.             Else
  52.                 data = Mid(data, InStr(data, vbLf) + 1)
  53.             End If
  54.             If Len(Trim(data)) = 0 Then
  55.                 Exit Do
  56.             End If
  58.             objWriter.WriteLine(data)
  59.             page = page + 1
  61.             i = i + 1
  63.         Loop
  64.         objWriter.Close()
  66.         Call ProcessExcel(CurPath)
  68.         'The Excel Module closes the application after finish.
  70.     End Sub

And here is the GetUrlData Function...

Expand|Select|Wrap|Line Numbers
  1.     Private Function GetUrlData(ByVal strUrl, ByVal strMethod, ByVal strData)
  4.         objHTTP.Open(strMethod, strUrl)
  6.         If strMethod = "POST" Then
  7.             objHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  8.         End If
  10.         objHTTP.Option(6) = False
  12.         objHTTP.Send(strData)
  14.         If Err.Number <> 0 Then
  16.             GetUrlData = "ERROR: " & Err.Description & vbCrLf & Err.Source & " (" & Err.Number & ")"
  17.         Else
  19.             GetUrlData = objHTTP.ResponseText
  20.         End If
  22.     End Function
Feb 27 '14 #1
Share this Question
Share on Google+
12 Replies

P: 142
If it helps any, I've used some msgbox's to test the variables in this trouble section. On the 2nd call to GetUrlData (data = GetUrlData(URL & "/signin", "POST", "formtoken=" & token & "&username=" & strUser & "&password=" & strPW & "&sign_in_submit=foo")), all of the variables are populated (token, strUser, and strPW).

So if anyone has any thoughts on how I could troubleshoot (step through, use msgbox's, etc) the GetUrlData Function, that would be helpful.

Feb 28 '14 #2

Expert Mod 5K+
P: 9,197
The program was compiled as 32-bit? I'm part of the C/C++ world and a 64-bit program will never work on a 32-bit machine. Just curious.
Mar 1 '14 #3

P: 142
Thanks for the insight. Unfortunately (this is where the true programmers role their eyes), I don't have enough knowledge to know how it was compiled. I am using Visual Studio Express, and I never had to formally compile it to use the exe that was automatically created. If someone has insight on how to compile differently for 32 vs 64 bit in Visual Studio Express, I am all ears.

That said, the section that is having trouble is just going out to a website, logging in, and pulling data. Why would that act any differently between 32 bit and 64 bit?
Mar 1 '14 #4

Expert Mod 5K+
P: 9,197
There are different Visual Studio products for 32 and 64 bit. In my case I can only create a Win32 project which gives me a 32-bit object file. On the 64-bit operating system this 32-bit program won't run because of instruction set incompatibility. However, Microsoft has written a dll called WOW (windows-on-windows)which reads my 32-bit program as data and quick like a bunny translates the instructions to 64-bit. The effect is that 32-bit programs appear to run on the 64-bit machine. Naturally, they run slower due to the machinations of WOW.

However, this does not work the other way. There is no support for 64-bit code on a 32 bit OS.

If your Visual Studio express has a Win32 project capability, then create a Visual Basic project, add your code files and build. The resultant code will work on the 32bit OS and because of WOW will also run (slower) on a 64bit OS.

I am curious now so please let me know what happens.
Mar 1 '14 #5

P: 142
I read up a bit on how to compile in 32 bit, and I saw to chose x86 as the platform target. I did this, then select Build Solution, and it apparently completed with 2 warnings...

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVer sion.targets(2151,5): warning MSB3284: Cannot get the file path for type library "2df8d04c-5bfa-101b-bde5-00aa0044de52" version 2.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVer sion.targets(2151,5): warning MSB3284: Cannot get the file path for type library "00020813-0000-0000-c000-000000000046" version 1.7. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

Not sure what these are. Could they be causing the problem? No change in results when I ran it.
Mar 1 '14 #6

Expert Mod 5K+
P: 9,197

P: 142
So I tried adding a reference to one of these type libraries (WIN.TLB or WIN32API.TXT). I didn't see any of them as a choice in the Type Libraries listed. I did add a reference to Win32_TPM 1.0 Type Library, with no change in function.

Do I need to download one of those 2 type libraries specifically?
Mar 2 '14 #8

Expert Mod 5K+
P: 9,197
The type libraries are part of COM which underlies VB Automation by implementing IDispatch. There libraries need to be registered. I expect there is a RegTypeLib call in there somewhere with an argument for the type library GUID but no way for the compiler to figure out the path to the type library so it can b registered.

I suspect you will need a better VB man then me.
Mar 6 '14 #9

P: 142
Thanks so much for your insight. I wish I had the skill to carry out the references to the libraries that you are talking about. Maybe eventually. :)

So the gauntlet has been thrown... Any "better VB men" (or women) want to chime in?
Mar 6 '14 #10

P: 299
Heya, Brad! Long time no chat. I decided to go back through your project and I noticed that you are referencing Microsoft Excel and Office 14.0. Are your 32bit machines running Office 2010? Microsoft Excel and Microsoft Office 12.0 Object Library would need to be used for Excel/Office 2007.

Also, I tested the application on a 32 bit machine just now and I was getting the same error.. telling me that my username or password was wrong. So I very slowly typed my password using the keypad for numbers and making sure I only typed 1 letter at a time and I got past the invalid username/password but was faced with the application telling me it was trying to access memory that was corrupt. I finally decided to take off the masking of the password and noticed that it was turning my password into this: —az....That's definitely not what I was typing. I realized it was the encryption you were doing. So, I modified the code to use no encryption and it worked...part of the time. The way your events are setup to store data is a bit off. I may not always "leave" a textbox, which means it doesn't have anything new stored, hence, forgetting my username, network, and/or password. I was still getting the corrupt memory issue but I guess we can work on that when the time comes and after you've figured out how you'd like to fix what I've mentioned. On another note, I don't know that you can use RC4 encryption for a password and have no method of deciphering. You'd have to set up some sort of decipher method for that encryption for the password to be properly read and used in the URL when connecting to
Mar 6 '14 #11

P: 142
Greetings Luke! Glad you jumped in!

With regards to the Office 2010... There may be some users that have 2010, but most will have 2007. But... The errors, as you can see, are happening before it even gets to the Excel portion of the code.

The errors that you got are exactly what I am getting. The RC4 encryption actually does have a decryption piece to it, but maybe for some reason it is not working consistently on 32 bit machines?

This is what I have for the password field, and saving it to the My.Settings.

Expand|Select|Wrap|Line Numbers
  1.     Private Sub PWChg(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPW.Leave
  2.         My.Settings.appPW = RC4(Me.txtPW.Text, strK)
  3.         Me.txtPW.Text = My.Settings.appPW
  4.     End Sub

Do you think that using the "on leave" event is the wrong way to do that?
Mar 7 '14 #12

P: 142
I just tried without any encryption, and still got the Username/Password error (worked great with Win 7 - 64 bit).
Mar 7 '14 #13

Post your reply

Sign in to post your reply or Sign up for a free account.