Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 20th, 2008, 4:43 AM   #1
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
Difference between test and production?

I have this code that will print and email results of pings. On my test pc, it works great, but on the production pc, it prints/emails multiple lines of the errors. I've tried re-publishing it and re-installing it and it's the same each time. The only thing I've changed from the time it worked correctly to now is making the ping loop 4 times for each entry. I've gone through the code several times and I can't figure out why it work differently on 2 pcs.
vb Syntax (Toggle Plain Text)
  1. Do While sr.EndOfStream = False
  2. 'Read in a line from file
  3. linecheck = sr.ReadLine
  4.  
  5. 'Check that line read isn't empty string and that it contains 2 parts, otherwise discard
  6. If ((linecheck = "") Or (linecheck.Contains(",") = False)) Then
  7. Else
  8. 'If ok, split read line and put in entry
  9. entry = linecheck.Split(",")
  10. Dim Ping As Ping = New Ping
  11. Dim PingReply As PingReply
  12. success = 0
  13. For t As Integer = 0 To 3
  14. If entry(0) = "y" Then
  15. PingReply = Ping.Send(entry(1), 2000)
  16. 'Set current activity on toolstrip and cause repaint
  17. tssActivity.Text = "Current Task: Pinging " & entry(2) & ": " & entry(1)
  18. tssActivity.Invalidate()
  19. 'Set result parts 1 & 2 to current ping entry
  20. line(0) = entry(2) & ": "
  21. line(1) = entry(1)
  22. 'Set result part 3 (line(2)) to ping if success, error message if failed
  23. If PingReply.Status = IPStatus.Success Then
  24. line(2) = PingReply.RoundtripTime.ToString
  25. success += 1
  26. Else
  27. line(2) = PingReply.Status.ToString
  28. errtemp = line(0) & Chr(13) & Chr(10) & line(1) & Chr(9) & Chr(9) & "Ping: " & line(2) & Chr(13) & Chr(10)
  29. End If
  30. End If
  31. Ping.Dispose()
  32. Next
  33. End If
  34.  
  35. If success = 0 Then
  36. errstring += errtemp
  37. End If
  38.  
  39. 'Set result string (line(3))
  40. line(3) = line(0) & Chr(13) & Chr(10) & line(1) & Chr(9) & Chr(9) & "Ping: " & line(2) & Chr(13) & Chr(10)
  41. rtbResult.Text += line(3)
  42. 'kill ping after used
  43. rtbResult.Invalidate()
  44. Me.Refresh()
  45. Loop

The lines of code I've added are 12, 13, 25, 32, and 35-37, otherwise, the program is unchanged. Works correctly from the IDE but not from the exe.

The weirdest thing about it is, sometimes it duplicates the message 3 or 4 times, sometimes as much as 15 times on the same entry. Each duplication is on a new line. Is it possible that it's not disposing the ping and just pinging the same server on the next round?

Unfortunately I can't attach to the process because I'm using VB Express.
Jabo is offline   Reply With Quote
Old Apr 20th, 2008, 8:50 AM   #2
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 Narue is on a distinguished road
Re: Difference between test and production?

If your program works during debug but not release, or on one machine but not another, it's usually a concurrency or timing issue. You've got multiple threads or processes vying for the same resources, or you're trying to do something too fast or too slow.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Apr 20th, 2008, 6:51 PM   #3
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
Re: Difference between test and production?

Thanks Narue, that gives me something to chew on lol. If my program is multi-threaded, it's not intentional, since I know pretty much jack about multi-threading.

Since I have a 2 second timeout on my pings, maybe I should put a 3 second timer on each ping.
Jabo is offline   Reply With Quote
Old Apr 20th, 2008, 8:31 PM   #4
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 748
Rep Power: 3 Jimbo is on a distinguished road
Re: Difference between test and production?

Changing the timers won't necessarily fix the problem. Often the problem lies in accessing a shared resource or accessing an object. Also, if your program has a graphical UI (which I'm guessing, since you have it repaint), it is almost certainly multi-threaded.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Apr 21st, 2008, 7:06 AM   #5
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 Narue is on a distinguished road
Re: Difference between test and production?

>maybe I should put a 3 second timer on each ping.
Only if you plan to use that for locating the source of the problem. Don't change a timer and expect the problem to be solved, that's like sweeping dirt under a rug.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Apr 22nd, 2008, 6:19 PM   #6
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
Re: Difference between test and production?

Well, I fixed the problem by moving the check for success into the IF statement. Now it only prints one instance of each error.

I still don't know why this caused the error.

vb Syntax (Toggle Plain Text)
  1. Do While sr.EndOfStream = False
  2. 'Read in a line from file
  3. linecheck = sr.ReadLine
  4.  
  5. 'Check that line read isn't empty string and that it contains 2 parts, otherwise discard
  6. If ((linecheck = "") Or (linecheck.Contains(",") = False)) Then
  7. Else
  8. 'If ok, split read line and put in entry
  9. entry = linecheck.Split(",")
  10. Dim Ping As Ping = New Ping
  11. Dim PingReply As PingReply
  12. success = 0
  13. For t As Integer = 0 To 3
  14. If entry(0) = "y" Then
  15. PingReply = Ping.Send(entry(1), 2000)
  16. 'Set current activity on toolstrip and cause repaint
  17. tssActivity.Text = "Current Task: Pinging " & entry(2) & ": " & entry(1)
  18. tssActivity.Invalidate()
  19. 'Set result parts 1 & 2 to current ping entry
  20. line(0) = entry(2) & ": "
  21. line(1) = entry(1)
  22. 'Set result part 3 (line(2)) to ping if success, error message if failed
  23. If PingReply.Status = IPStatus.Success Then
  24. line(2) = PingReply.RoundtripTime.ToString
  25. success += 1
  26. Else
  27. line(2) = PingReply.Status.ToString
  28. errtemp = line(0) & Chr(13) & Chr(10) & line(1) & Chr(9) & Chr(9) & "Ping: " & line(2) & Chr(13) & Chr(10)
  29. End If
  30. End If
  31. Ping.Dispose()
  32. Next
  33. If success = 0 Then
  34. errstring += errtemp
  35. End If
  36. End If
  37.  
  38.  
  39. 'Set result string (line(3))
  40. line(3) = line(0) & Chr(13) & Chr(10) & line(1) & Chr(9) & Chr(9) & "Ping: " & line(2) & Chr(13) & Chr(10)
  41. rtbResult.Text += line(3)
  42. 'kill ping after used
  43. rtbResult.Invalidate()
  44. Me.Refresh()
  45. Loop
Jabo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC