How do I even start debugging this.

G

Guest

First off, I'm a hardware/OS guy. I just write code on the side and I'm
completely self taught - so bear in mind my total lack of expertise.

I have a program originally written in VB2003 using the dotnet 1.1
framework. The program makes extensive use of Win32 API calls to help manage
and track remote access sessions with out clients. I've left it running for
days at a time on my system with no problems. It has always been stable.

I recently upgraded the program to VB2005 using the upgrade wizard. It
seemed to port cleanly with only minor cleanup needed (such as 2005 needing
more explicit references. i.e. "if result = dialogresult.yes" becoming "if
result = windows.forms.dialogresult.yes"). The problem is that under dotnet
2.0 the program is unstable. If I leave it minimized for several hours then
try to acess it from the taskbar, the program form will just display as a
blank white form. No actual error occurs, the form is just white. Task
manager shows the process running normally. It goes to not-responding when
you try to close it and has to be force closed. I have try...catch clauses
around everything and as far as I can tell, no exceptions are occuring. The
problem only occurs if the program has been idle for a long time. It's as if
Windows has simply decided to quit drawing the form.

Obviously no one can tell me exactly what's happening, my problem is that I
don't have even the vaguest idea how to start debugging something like this.
How do you troubleshoot a program that just hangs without causing an error?

Can somebody recommend an article or website (or even a book) that gives a
general debugging process for something like this?
 
G

Guest

Ken,

As I mentioned, I'm a hardware guy. I don't even know what "update the user
interface from a background thread" means.

I'm not deliberately creating seperate threads. Basically there is a startup
module that sets some global parameters and structures then displays frmMain.
Any threads that are created are dotnet's doing.

What part of the code would you find useful? I'm clueless here :)

As far as I know, my code should be doing absolutely nothing when the
program is minimized. There IS a timer that does an API call every few
seconds to check for dropped RAS connections, but it always worked under
vb2003 and I've gone so far as to remove the timer control and associated
timer1_tick procedure from the vb2005 version with no effect.

Here's an overview. The main form has two main sections. A tree view on the
left side and a panel area on the right side. Different panels are displayed
depending on where you are in the tree.

The tree contains a list of our clients and under each client a list of
their systems. Each client has a RAS (VPN) phonebook entry associated with
them.

Basically you select a system from the tree view and click a "connect"
button. The program makes the VPN connection then starts an RDP session to
the selected system. When the RDP session terminates, it disconnects the VPN
and adds and entry to a logbook file.

Most of the code involves adding and deleting clients and systems to/from
the tree and setting various connection options. The core of the program is
just a wrapper around API calls that do the real work.
 
J

Jeff Allan

Why would you upgrade if you didn't need to?
The program was stable on 03 right?
 
R

rowe_newsgroups

Obviously no one can tell me exactly what's happening, my problem is that I
don't have even the vaguest idea how to start debugging something like this.
How do you troubleshoot a program that just hangs without causing an error?

You might create a simple log system. Whenever you're about to perform
an action you could write to a file (or database or something else)
that says what the action is and what the current time is. You could
even start out vague, like writing a line whenever you enter a method
or property, and then after finding which sub has the problem, use this
same method for each line in the sub. The bad part is that this will
tell you where you had a problem (or at least what the last command to
execute was) but it won't tell you what the problem was.
As I mentioned, I'm a hardware guy. I don't even know what "update the user
interface from a background thread" means.

Basically, the User Interface (UI) thread creates all the controls on
your form. It is the only thread that is allowed to change any of the
properties of the controls it created. If any other thread tries to
change those properties the program will throw a cross-thread
exception. The article Ken mentioned describes the "proper" way to get
around this. If you need to know more please let us know and we'll try
to explain.

Thanks,

Seth Rowe
 
G

Guest

Good question.
Partly just to gain experience with vb2005. But I also want to add some
capability that I can only do (easily) with the 2.0 framework. One of the
proposed enhancement would require me to know the sessionid the program is
running under but process.sessionid is not available in the 1.1 framework. I
also want to make some changes to the call logging system which will be most
easily accomplished by using an unbound datagridview control. A control
that's not available in vb2003.
 
S

Steve Long

Hmmmm, I thought this was a winform app. In that case, there's a process ID
that you can get using the process class (available also in the 1.1 version
of the framework and vs2003). I'm only assuming that's what you want though.
Check it out.

Steve
 
G

Guest

Processid yes. I need the sessionid. Sessionid lets me know which session in
a multi-user envionment (Such as terminal server or fast user switching in
XP) the program is running in. I haven't figured out any way to retrieve that
under 1.1
 
R

Robert

The tree contains a list of our clients and under each client a list of
their systems. Each client has a RAS (VPN) phonebook entry associated with
them.

Basically you select a system from the tree view and click a "connect"
button. The program makes the VPN connection then starts an RDP session to
the selected system. When the RDP session terminates, it disconnects the
VPN
and adds and entry to a logbook file.

Most of the code involves adding and deleting clients and systems to/from
the tree and setting various connection options. The core of the program
is
just a wrapper around API calls that do the real work.

Could it be a network timeout issue? I have seen big delays when domain
servers get bogged down.

Are you checking the API hResults properly? There are many differences
between them. Some <> 0, sometimes negative numbers are bad, sometimes <32
is bad, etc.

Is the problem intermittant? or does it lock up every time?

Get ProcessExplorer from SysInternals.Com. Be sure you are not leaking
connections,
threads, handles, or anything else. Also, get TCP view from there, and
check your
process.

Maybe it is a client problem on one of the workstations.

Can you test this locally? IE two machines in arms reach, where this can be
replicated?
With no other connections.


And you are sure the ONLY difference is VS2005?
 
M

mg

Doug said:
I have a program originally written in VB2003 using the dotnet 1.1
framework. The program makes extensive use of Win32 API calls to help manage
and track remote access sessions with out clients. I've left it running for
days at a time on my system with no problems. It has always been stable.

Doug,
I have written an almost identical application in VB2005. Here is the
code I use to start a RAS VPN connection and launch either the RDP
client or VNC:

Dim spVPN As New Process()
With spVPN
.StartInfo.FileName = oSettings.RASDialPath
.StartInfo.UseShellExecute = False
.StartInfo.RedirectStandardOutput = True
.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
.StartInfo.CreateNoWindow = True
.StartInfo.Arguments = VPNargs
.Start()
sOut = spVPN.StandardOutput.ReadToEnd
.WaitForExit(1000)
Application.DoEvents()
ec = .ExitCode
End With
If Not spVPN Is Nothing Then spVPN.Close()

Debug.Print("exit code: [" & CStr(ec) & "]" & vbCrLf & sOut)
If ec = 0 Then
Dim sp As New Process()
With sp
.StartInfo.FileName = launchApp
.StartInfo.UseShellExecute = False
.StartInfo.WorkingDirectory = My.Application.Info.DirectoryPath
.StartInfo.Arguments = launchCMD
.Start()
.WaitForExit(1000)
Application.DoEvents()
End With
If Not sp Is Nothing Then sp.Close()
Else
Select Case ec
Case 623
MsgBox("Support RAS phonebook entry not found.", MsgBoxStyle.OkOnly,
"Connection Error")
Case Else
MsgBox(sOut, MsgBoxStyle.OkOnly, "Connection Error")
End Select
End If

It uses a dummy RAS connectoid (the the right security/VPN settings)
that you can call with rasdial and command line switches.

One thing I have noticed is that RAS dial/hangup is very sensitive to
trying to 'rush' it when hanging up. Any help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top