|
-
Jun 28th, 2012, 10:23 AM
#1
Thread Starter
New Member
VB.NET app won't run correctly the first run
Hello, I work in VB.NET and I really need help.
In brief, the program that I'm working with is designed to run different machines. To test the machines, the user uses program's testgraph. The issue is that sometimes the testgraph won't work (shows blank fields). I noticed, that the graph won't work only the first time the program runs after I reboot PC. However, if I exit the program after the first run and run the program again (without restarting pc), the issue goes away and the test graph works.
Inside a program there are many forms such as frmmain.frm, frmtestgraph.frm etc. It seems like the first time the program runs testgraph form won't load. But it loads after I manually click the button "Test Graph" and then it sits in the memory which allows it to work on the second launch of the program. After rebooting the PC, memory clears and testgraph won't work.
I tried to use breakpoints to compare what code runs when it works and when it doesn't. In two cases the program goes the same paths. However, on the one that works I can see changes when the particular line of code is executed. On the other one, it just goes over the line without making any changes. For example, the following line makes the testgraph button enabled in the working case: frmtestgraph.btntestraph.enabled = true
In the not working case, the same line will still be executed but won't make that button enabled. In other words, I can see that it runs over it by pressing f8 and it won't make any change.
I'm confused and don't know what to do. Any ideas will be greatly appreciated.
Thank you,
Paul.
-
Jun 28th, 2012, 10:48 AM
#2
Re: VB.NET app won't run correctly the first run
frmTestGraph sounds like the name of the form rather than an instance. If that is the case, you are using default instances, and much (though not all) of what you describe sounds like a symptom of using default instances....which are evil because of the confusion they cause.
Another question would be: Is this running on a 64-bit OS, and if so, how much is happening in the Load event of the form, especially the startup form?
My usual boring signature: Nothing
 
-
Jun 28th, 2012, 06:04 PM
#3
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
Thanks for quick reply!
yes, frmTestGraph is the name of the form and the instance name of the form at the same time, so they both the same. Whenever I write code in one form and refer to some object in the other form I write like that for example:
frmTestGraph.buttonGraph.Enabled = True
And it works, I never had any problems with the names. But for some reason during the first run of the program, not all components are loading (probably).
yes, it's running on 64 OS. In the startup form program sets several variables, checks for the connection of some devices and starts timers (1 timer runs continuously, and few more being enabled when needed)
-
Jul 2nd, 2012, 07:31 AM
#4
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
One more thing,
I looked in the System event log and found an error saying that one of the drivers for my device fails to load. Probably, this is my issue. Gonna be keep looking.
-
May 14th, 2013, 01:35 PM
#5
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
Still having the same issue. Please help!
-
May 14th, 2013, 02:13 PM
#6
Re: VB.NET app won't run correctly the first run
Could you explain this a bit more? Are you still getting this when you get the error about the device failing to load? Do you know what device, or anything about it?
My usual boring signature: Nothing
 
-
May 14th, 2013, 02:59 PM
#7
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
It's still not loading correctly the first run. But I don't see any errors in the system log anymore, so probably this is not it. I read online and found that this is a known bug of vb.net when vb skips the lines of code. For instance, when stepping through, it's going over the line which says: Me.Graph.PlotY(plotData), but the graph field will still be empty
However, in my case, it does it only on the first run after rebooting the PC.
Is it possible to fix it but making the automatic restart of the program. For example, if the program was launched the first time since the computer was turned on? If so, then how can I code it?
-
May 15th, 2013, 12:30 PM
#8
Re: VB.NET app won't run correctly the first run
Do you have any Exception handling in your load event? If not, you really really should. You should also not be using default instances (if you actually are). That is a dreaded curse of a "feature" that causes more problems than its actually worth in .NET (I think default instances carried over from the VB era).
-
May 15th, 2013, 01:57 PM
#9
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
yes, I have some try blocks in my forms, however, the code doesn't seem to hit it.
No, default instances are not being used. Everything has its own specific name like btnGraph etc.
Also, I ran the task manager during the first run and during the second run to compare the services. All of the services are the same, nothing new being opened during the second run. So it leaves me with an idea that the problem is caused by the executable file only.
-
May 15th, 2013, 01:58 PM
#10
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
yes, I have some try blocks in my forms, however, the code doesn't seem to hit it.
No, default instances are not being used. Everything has its own specific name like btnGraph etc.
Also, I ran the task manager during the first run and during the second run to compare the services. All of the services are the same, nothing new being opened during the second run. So it leaves me with an idea that the problem is caused by the executable file only.
-
May 15th, 2013, 04:46 PM
#11
Re: VB.NET app won't run correctly the first run
I specifically mention the Load routine because on 64 bit systems, the load routine exceptions (that are not caught) are swallowed by the OS. This is by design (stupid to me, but whatever).
-
May 16th, 2013, 07:23 AM
#12
Thread Starter
New Member
Re: VB.NET app won't run correctly the first run
Yes, I do have them there too. So it might be a 64bit processor problem?
-
May 16th, 2013, 08:03 AM
#13
Re: VB.NET app won't run correctly the first run
 Originally Posted by paulCWT
Yes, I do have them there too. So it might be a 64bit processor problem?
No, if you weren't catching exceptions, then possibly. However, you are so that might rule out the problem. What you should be doing is setting a breakpoint in your form's load routine and see if it gets that far. If it does, step through the entire load routine to see what happens.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|